diff --git a/.zk/notebook.db b/.zk/notebook.db index 39cc7f6..cf49e3b 100644 Binary files a/.zk/notebook.db and b/.zk/notebook.db differ diff --git a/zk/Single_file_Python_scripts.md b/zk/Single_file_Python_scripts.md index 35d1f6d..f8f51df 100644 --- a/zk/Single_file_Python_scripts.md +++ b/zk/Single_file_Python_scripts.md @@ -25,3 +25,21 @@ When you run a script (module) Python assigns the string `__main__` to the If you run the script as an import into another script, the `__name__` attribute of the imported module is set to the module name, not `__main__`. + +Everything can go under the `__main__` conditional, or, for better readability, +you can define a `main` function that is then invoked, e.g: + +```py + +def main(): + # Do some stuff + + +if __name__ == "__main__": + main() + +``` + +## Related notes + +![Python modules and imports](./Python_modules_and_imports.md)