5,337
edits
(→Misc) |
|||
Line 108: | Line 108: | ||
===Misc=== | ===Misc=== | ||
If you are writing a script with functions you want to be included in other scripts, use <code>__name__</code> to detect if your script is being run or being imported. | If you are writing a script with functions you want to be included in other scripts, use <code>__name__</code> to detect if your script is being run or being imported. | ||
[https://stackoverflow.com/questions/419163/what-does-if-name-main-do What does if __name__ == "__main__" do?] | |||
<syntaxhighlight lang="python"> | <syntaxhighlight lang="python"> | ||
if __name__ == "__main__": | if __name__ == "__main__": |