How about some syntactic sugar for " __name__ == '__main__' "?
Ian Kelly
ian.g.kelly at gmail.com
Wed Nov 12 17:19:09 EST 2014
More information about the Python-list mailing list
Wed Nov 12 17:19:09 EST 2014
- Previous message (by thread): How about some syntactic sugar for " __name__ == '__main__' "?
- Next message (by thread): How about some syntactic sugar for " __name__ == '__main__' "?
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]
On Wed, Nov 12, 2014 at 3:09 PM, Chris Kaynor <ckaynor at zindagigames.com> wrote: > I was thinking along the lines of replacing: > > if __name__ == "__main__": > <<<block of code>>> > > with > > @main > def myFunction() > <<<<block of code>> > > Both blocks of code will be called at the same time. 99% of the time the content of <<<block of code>>> is just "main()", so then you're proposing replacing this: if __name__ == "__main__": main() with this: @main def myFunction(): my_main() Which feels redundant to me. Why have a function here that does nothing but call another function? I think if this is the goal then a simple predicate would be clearer: if is_main_module(): main()
- Previous message (by thread): How about some syntactic sugar for " __name__ == '__main__' "?
- Next message (by thread): How about some syntactic sugar for " __name__ == '__main__' "?
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]
More information about the Python-list mailing list