[Python-ideas] Replacing the if __name__ == "__main__" idiom (was Re: making a module callable)
Chris Angelico
rosuav at gmail.com
Mon Nov 25 16:15:36 CET 2013
On Tue, Nov 26, 2013 at 1:55 AM, Ron Adam <ron3200 at gmail.com> wrote:
> But when there is only *one* of something, and you aren't manipulating the
> parts, then "is" should be ok. __name__ would be bound directly to
> __main__'s string object, so "is" or "==" should always work for that case.
Really? Is this something that's guaranteed? I know the CPython
compiler will optimize a lot of constants, but can you really be sure
that this is safe?
ChrisA
More information about the Python-ideas
mailing list