diff --git a/.zk/notebook.db b/.zk/notebook.db index 38525d5..39cc7f6 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 a45fd41..35d1f6d 100644 --- a/zk/Single_file_Python_scripts.md +++ b/zk/Single_file_Python_scripts.md @@ -2,11 +2,26 @@ id: atzw title: Single_file_Python_scripts tags: [] -created: Friday, April 26, 2024 +created: Friday, April 26, 2024 --- + # Single_file_Python_scripts +## Basic architecture -## Related notes +```py +#! /usr/local/bin/python3 +import sys +if __name__ == "__main__": + all_args = sys.argv + specific_arg = sys.argv[0] + # Main functionality... +``` + +When you run a script (module) Python assigns the string `__main__` to the +`__name__` attribute to the script that is being executed. + +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__`.