Python needs an actual default function
Python needs an actual default function


Also, do y'all call main() in the if block or do you just put the code you want to run in the if block?
You're viewing a single thread.
I would put my code in a
def main()
, so that the local names don't escape into the module scope:if __name__ == '__main__': def main(): print('/s') main()
(I didn't see this one yet here.)
17 0 ReplyI'm a little new to Python standards. Is this better or worse than putting the
def main():
outside the if statement (but callingmain()
inside it)5 0 ReplyI intended this an sarcastic example; I think it's worse than putting the main outside of the branch because of the extra indent-level. It does have an upside that the
main()
doesn't exist if you try import this as an module.4 0 ReplyI thought confusion about indent levels was the whole point of using python
6 0 ReplyBut it feels like main function should not be indented
2 0 Reply