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

Chris Angelico rosuav at gmail.com
Thu Apr 26 00:19:22 EDT 2012


On Thu, Apr 26, 2012 at 1:50 PM, Adam Skutt <askutt at gmail.com> wrote:
> On Apr 25, 8:01 pm, Steven D'Aprano <steve
> +comp.lang.pyt... at pearwood.info> wrote:
>> 2) The "is" operator always has the exact same semantics and cannot be
>> overridden. The id() function can be monkey-patched.
>
> I can't see how that's useful at all.  Identity is a fundamental
> property of an object; hence retrieval of it must be a language
> operation.
> ...
> The other solution is to do what Java and C# do: banish id() entirely
> and only provide 'is' (== in Java, Object.ReferenceEquals() in C#).

The 'is' operator is a language feature. The id() function is not.

ChrisA



More information about the Python-list mailing list