[Python-Dev] Generator methods - "what's next" ?

Firephoenix firephoenix at wanadoo.fr
Sun Apr 5 13:31:48 CEST 2009

Hello everyone

I'm a little confused by the recent changes to the generator system...

I basically agreed with renaming the next() method to __next__(), so as 
to follow the naming of other similar methods (__iter__() etc.).
But I noticed then that all the other methods of the generator had 
stayed the same (send, throw, close...), which gives really weird (imo) 
codes :


Browsing the web, I've found people troubled by that asymmetry, but no 
remarks on its causes nor its future...

Since __next__(), send() and others have really really close semantics, 
I consider that state as a python wart, one of the few real ones I can 
think of.

Is there any plan to fix this ? Either by coming back to the next() 
method, or by putting all the "magical methods" of generators in the 
__specialattributes__  bag ?

    send(it, 5)
    throw(it, Exception())

Thanks a lot for the information,

More information about the Python-Dev mailing list