2 ms·
I've only done a little Python, so am not up on the finer points of the language, so a question if I may. I'm a bit confused by the use of the if __name__ =
by tzs 10y ago
I've only done a little Python, so am not up on the finer points of the language, so a question if I may.
I'm a bit confused by the use of the
if __name__ == "__main__":
construct in this script. My understanding of that construct was that it is true when Python is invoked directly on the containing file, and is false if the file is being invoked as a module loaded from something else.
In your script, the parts that are outside the "if __name__" construct do not appear to be things that would be useful for something else to load as a module. So my question is why aren't they inside the "if __name__" construct?
- tptacek 10y agoThe Python idiom is to guard pretty much just the main() function; the Python package system does the job of keeping the rest of the details from leaking.
- deleted 10y ago[deleted]