import
command
In [1]:
import module_a
print module_a.double(5)
In [2]:
import module_a
import module_b
from
statement to import name from a module directly
In [3]:
from module_b import triple
print triple(5)
In [4]:
from module_a import *
print 'single', single(5)
print 'double', double(5)
In [5]:
print _test_func
In [6]:
print module_a._test_func
In [7]:
from module_a import _test_func
In [8]:
print _test_func
__name__
contains the module name.
In [9]:
print module_a.__name__
In [10]:
print __name__
sys.path is initialized from:
In [11]:
import examples
In [12]:
import mathlib
In [1]:
import sys
sys.path.append('./examples')
In [2]:
import mathlib
__init__.py
In [3]:
mathlib.random_variable
In [4]:
mathlib.self_introduction()
In [5]:
import mathlib.ndarray
print mathlib.ndarray.sum1d([1,2,3])
In [8]:
mathlib.ndarray.sum1d
Out[8]:
In [9]:
import mathlib.random_variable as random_variable
print random_variable.draw_uniform(0, 100)
In [10]:
s = random_variable
In [11]:
s.draw_uniform(0, 100)
Out[11]:
In [12]:
from mathlib.linalg import dot
print dot.dot1d([1,2,3], [1,2,3])
In [ ]: