Python: Difference between revisions
Jump to navigation
Jump to search
Created page with " Category:Python Category:Programming" |
No edit summary |
||
Line 1: | Line 1: | ||
* Every file of Python source code that ends in <code>.py</code> is a module - no special code or naming is required. | |||
* <code>dir</code> fetches all names available inside a module: <code>dir(modname)</code> | |||
* Each file is a self-contained namespace. | |||
* reloads are not transitive, so reloading module A which imports module B does not reload B. | |||
* To run a script: <code>exec(open('script.py').read())</code> | |||
[[Category:Python]] | [[Category:Python]] | ||
[[Category:Programming]] | [[Category:Programming]] |
Revision as of 21:09, 11 March 2018
- Every file of Python source code that ends in
.py
is a module - no special code or naming is required. dir
fetches all names available inside a module:dir(modname)
- Each file is a self-contained namespace.
- reloads are not transitive, so reloading module A which imports module B does not reload B.
- To run a script:
exec(open('script.py').read())