why () is () and [] is [] work in other way?

Bernd Nawothnig Bernd.Nawothnig at t-online.de
Sat Apr 21 09:02:00 EDT 2012


On 2012年04月20日, dmitrey wrote:
> I have spent some time searching for a bug in my code, it was due to
> different work of "is" with () and []:
>>>> () is ()
> True

You should better not rely on that result. I would consider it to be
an implementation detail. I may be wrong, but would an implementation
that results in
() is () ==> False
be correct or is the result True really demanded by the language
specification?
>>>> [] is []
> False

Same for that.
>> (Python 2.7.2+ (default, Oct 4 2011, 20:03:08)
> [GCC 4.6.1] )
>> Is this what it should be or maybe yielding unified result is better?

See above.
Bernd
-- 
"Die Antisemiten vergeben es den Juden nicht, dass die Juden Geist
haben - und Geld." [Friedrich Nietzsche]


More information about the Python-list mailing list

AltStyle によって変換されたページ (->オリジナル) /