Autosave: 2024-04-28 12:00:05
This commit is contained in:
parent
26a5334a8e
commit
e6390b6e0a
2 changed files with 18 additions and 0 deletions
BIN
.zk/notebook.db
BIN
.zk/notebook.db
Binary file not shown.
|
@ -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
|
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__`.
|
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
|
||||||
|
|
||||||
|

|
||||||
|
|
Loading…
Add table
Reference in a new issue