On Jan 22, 2008 3:46 PM, Daniel Stutzbach <[EMAIL PROTECTED]> wrote: > On Jan 22, 2008 1:26 PM, tomer filiba <[EMAIL PROTECTED]> 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 "<stdin>", line 1, in <module> > TypeError: an integer is required
Possibly. I guess it depends on the use case. It would be nice to research this more, e.g. figure out how much code needs to be changed to make each of these possible changes, and how likely there will be a use case. -- --Guido van Rossum (home page: http://www.python.org/~guido/) _______________________________________________ Python-Dev mailing list Python-Dev@python.org http://mail.python.org/mailman/listinfo/python-dev Unsubscribe: http://mail.python.org/mailman/options/python-dev/archive%40mail-archive.com