[Python-Dev] misbehaving contains (original) (raw)
Daniel Stutzbach daniel at stutzbachenterprises.com
Wed Jan 23 00:46:48 CET 2008
- Previous message: [Python-Dev] misbehaving __contains__
- Next message: [Python-Dev] misbehaving __contains__
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]
On Jan 22, 2008 1:26 PM, tomer filiba <tomerfiliba at gmail.com> wrote:
>>> class Foo(object): ... def contains(self, key): ... return 17 ... def eq(self, other): ... return 19 ... >>> >>> f=Foo() >>> f == 8 19 >>> 8 in f True
There are many places in the C implementation where a slot returns an int rather than a PyObject. There other replies in this thread seem to support altering the signature of the slot to return a PyObject. Is this setting a precedent that all slots should return a PyObject?
Consider the following third behavior:
class foo(object): ... def len(self): ... return 'foo' ... x = foo() len(x) Traceback (most recent call last): File "", line 1, in TypeError: an integer is required
-- Daniel Stutzbach, Ph.D. President, Stutzbach Enterprises LLC
- Previous message: [Python-Dev] misbehaving __contains__
- Next message: [Python-Dev] misbehaving __contains__
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]