Import and namespace cheats

Mostly stolen from here

Import a module, then show the global namespace

import math
dir()

look at the math namespace

dir(math)

Stuff within the math module is now available, but it needs to be accessed with math as prefix:

print(math.pi)
print(math.sin(math.pi/2))

import the pi variable from the math module:

from math import pi

import math but give it a new name:

import math as foo
print(foo.pi)

or import just an object from a module under a new name:

from math import pi as po
print(po)