getting help: help() help(int) help(thing)

Intro

Modules

import file        # Imports whole file, similar to #include, then use file.function1()
import path.file   # Can use a relative path, use . instead of /
import numpy as np # Can rename imported file/function/class
from file import function1, function2 # import only specific functions/classes
     # Can call function1 directly like this -> may get name conflicts

Note: a package is a collection of modules, whereas a module is usually a single .py

Instead of a main() in C++ we can have several ‘entry points’ in the project. The module which is called directly has its name set the main

if __name__ == "__main__":          # equivalent to main() in C++
# This .py was executed directly, not imported

We can write the code without this, but then the code is executed when we import the .py as a module

Basic Built-in Types

booleans: true false

integers: x = 1

floats: x = 1. x = 1.e0 1.E0 → usually map to double precision

complex numbers: x = 1 + 1j x = 1 + 1J