How about some syntactic sugar for " __name__ == '__main__' "?
rosuav at gmail.com
Thu Nov 13 01:54:55 CET 2014
On Thu, Nov 13, 2014 at 11:35 AM, Terry Reedy <tjreedy at udel.edu> wrote:
>> Safer - and more in line with the way
>> other such functions are written - would be a dunder function:
>> if __name__ == '__main__': __main__()
> I presume you mean that calling __main__ implicitly would be both consistent
> and safer. No code should be using that now.
That's what I mean. Like changing iter.next() to iter.__next__() in
Py3, it'd be using a name that emphasizes that the interpreter, not
userland code, should be calling this function.
Of course, it'd still be optional. Top-level code would be executed
top-down, same as it now is.
More information about the Python-list