[Python-ideas] Just main (original) (raw)
Matt Chaput matt at whoosh.ca
Tue Jun 19 00:39:14 CEST 2012
- Previous message: [Python-ideas] Just __main__
- Next message: [Python-ideas] Just __main__
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]
But a main function misses the whole point: that a module can be importable and runnable, and the if statement detects the difference. If you simply want a function that is always invoked as the main, then just invoke it:
def main(): blah blah main() No need for special names at all.
I'm afraid you're the one who's missed the point... the interpreter would only call main() if name == "main"
Some people will cry "magic", but to me this is about what makes sense when you explain it to someone, and I think main() makes more sense (especially to someone with experience in other languages) than "if name == "main""
Matt
- Previous message: [Python-ideas] Just __main__
- Next message: [Python-ideas] Just __main__
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]