June 2017
Beginner
352 pages
8h 39m
English
We're sometimes asked about the differences between Python modules, Python scripts, and Python programs. Any .py file constitutes a Python module, but as we have seen modules can be written for convenient import, convenient execution, or, using the if __name__ == "__main__" idiom, both.
We strongly recommend making even simple scripts importable since it eases development and testing so much if you can access your code from the Python REPL. Likewise, even modules which are only ever meant to be imported in production settings benefit from having executable test code. For this reason nearly all modules we create have this form of defining one or more importable functions with a postscript ...
Read now
Unlock full access