4 ms·
Nice little Python script I whipped up to poll Amazon Prime Now to get my Switch: https://gist.github.com/bryanhelmig/3225bf42e5d2b8fb0cb4b720ac2d3c3b https://g
by bryanh 9y ago
Nice little Python script I whipped up to poll Amazon Prime Now to get my Switch: https://gist.github.com/bryanhelmig/3225bf42e5d2b8fb0cb4b720ac2d3c3b https://gist.github.com/bryanhelmig/3225bf42e5d2b8fb0cb4b720...
- tzs 9y agoI'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 9y 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 9y ago[deleted]