On Jan 22, 2008 5:40 PM, Raymond Hettinger <[EMAIL PROTECTED]> wrote:
> [Daniel Stutzbach]
> > 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?
>
> I hope not.
[snip]
> And, would we lose the nice relationship expressed by:
>
> for elem in container:
> assert elem in container
We've already lost this if anyone really wants to break it::
>>> class C(object):
... def __iter__(self):
... return iter(xrange(3))
... def __contains__(self, item):
... return False
...
>>> c = C()
>>> for item in c:
... print item in c
...
False
False
False
Of course, anyone who decides to break their container classes in that
way is asking for trouble. ;-)
STeVe
--
I'm not *in*-sane. Indeed, I am so far *out* of sane that you appear a
tiny blip on the distant coast of sanity.
--- Bucky Katt, Get Fuzzy
_______________________________________________
Python-Dev mailing list
[email protected]
http://mail.python.org/mailman/listinfo/python-dev
Unsubscribe:
http://mail.python.org/mailman/options/python-dev/archive%40mail-archive.com