Importing Objects From Modules Into The Main Namespace: Python Scientific Lecture Notes, Release 2012.3 (Euroscipy 2012)
Importing Objects From Modules Into The Main Namespace: Python Scientific Lecture Notes, Release 2012.3 (Euroscipy 2012)
3 (EuroScipy 2012)
In [8]: demo.
demo.__builtins__ demo.__init__ demo.__str__
demo.__class__ demo.__name__ demo.__subclasshook__
demo.__delattr__ demo.__new__ demo.c
demo.__dict__ demo.__package__ demo.d
demo.__doc__ demo.__reduce__ demo.print_a
demo.__file__ demo.__reduce_ex__ demo.print_b
demo.__format__ demo.__repr__ demo.py
demo.__getattribute__ demo.__setattr__ demo.pyc
demo.__hash__ demo.__sizeof__
In [10]: whos
Variable Type Data/Info
--------------------------------
demo module <module ’demo’ from ’demo.py’>
print_a function <function print_a at 0xb7421534>
print_b function <function print_b at 0xb74214c4>
In [11]: print_a()
a
In [10]: reload(demo)
File demo2.py:
import sys
def print_a():
"Prints a."
print ’a’
print sys.argv
if __name__ == ’__main__’:
print_a()
Importing it:
In [11]: import demo2
b
Running it:
In [13]: %run demo2
b
a