[Python-ideas] x=(yield from) confusion [was:Yet another alternative name for yield-from]
Greg Ewing
greg.ewing at canterbury.ac.nz
Fri Apr 10 12:42:57 CEST 2009
Nick Coghlan wrote:
>>>>class Tricky(object):
>
> ... def __iter__(self):
> ... return self
> ... def next1(self):
> ... print "Next 1"
> ... Tricky.next = Tricky.next2
I just tried using a class like that in a for loop, and
it doesn't work. The next() method has to be defined in
the class, because it's actually a special method (it
has a slot in the type object).
> Greg - looks to me like you're going to have to disallow caching the
> method lookup in the PEP.
Even if it would work, I don't want to preclude a
valuable optimization for the sake of such an obscure
use case.
--
Greg
More information about the Python-ideas
mailing list