[Python-ideas] Replacing the if __name__ == "__main__" idiom (was Re: making a module callable)
Ron Adam
ron3200 at gmail.com
Mon Nov 25 15:55:18 CET 2013
On 11/24/2013 10:21 PM, Chris Angelico wrote:
> But then you have to explain why you're using 'is' to compare strings,
> which shouldn't normally be done. Why not just use == as per current?
In the case of generally parsing strings, that is correct as there may be
more than one of something that can match.
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.
Cheers,
Ron
More information about the Python-ideas
mailing list