context manager based alternative to Re: Proposal: === and !===

Chris Angelico rosuav at
Fri Jul 11 06:37:07 CEST 2014

On Fri, Jul 11, 2014 at 11:17 AM, Roy Smith <roy at> wrote:
> In article <mailman.11744.1405038048.18130.python-list at>,
>  Cameron Simpson <cs at> wrote:
>> Q: How many user support people does it take to change a light bulb?
>> A: We have an exact copy of the light bulb here and it seems to be
>>     working fine.  Can you tell me what kind of system you have?
> So, what are we talking about here?  my_lightbulb == your_lightbulb, or
> my_lightbulb === your_lightbulb, or my_lightbulb is your_lightbulb?  Or
> just sha1(my_lightbulb) == sha1(your_lightbulb)?

Probably type(my_lightbulb).__name__ == type(your_lightbulb).__name__,
knowing the reliability of support people...

I'm a bit wary of anything that makes a global, even if temporary,
change to comparisons' behaviours. What happens if, deep in a call
tree, something utterly unrelated happens to do a comparison of this
nature? Does C-level code have to check this flag before comparing
nans, or is this applicable only to the Python float objects and only
when compared in Python? Is isnan() still usable? (Consider that x!=x
== math.isnan(x) normally.)


More information about the Python-list mailing list