4 ms·
Ok, thanks, that makes sense. I knew that top-level variables are global, but didn't know that variables in __main__ share this property (which is e.g. differen
by zeptomu 9y ago
Ok, thanks, that makes sense. I knew that top-level variables are global, but didn't know that variables in __main__ share this property (which is e.g. different in the C language).
- AlecSchueler 9y agoif __name__ == __main__ is just a conditional on the top level scope.
- apenwarr 9y agoUsually people write an actual function called main(), and call it from the global level conditional, to avoid this oddness. The actual function called main() has no special meaning in python.