[Python-Dev] Re: anonymous blocks

Greg Ewing greg.ewing at canterbury.ac.nz
Tue Apr 26 04:47:37 CEST 2005


Tim Delaney wrote:
> There aren't many builtins that have magic names, and I don't think this 
> should be one of them - it has obvious uses other than as an 
> implementation detail.

I think there's some confusion here. As I understood the
suggestion, __next__ would be the Python name of the method
corresponding to the tp_next typeslot, analogously with
__len__, __iter__, etc.

There would be a builtin function next(obj) which would
invoke obj.__next__(), for use by Python code. For loops
wouldn't use it, though; they would continue to call the
tp_next typeslot directly.

> Paul Moore wrote: 
>> PS The first person to replace builtin __next__ in order to implement
>> a "next hook" of some sort, gets shot :-)

I think he meant next(), not __next__. And it wouldn't
work anyway, since as I mentioned above, C code would
bypass next() and call the typeslot directly.

I'm +1 on moving towards __next__, BTW. IMO, that's the
WISHBDITFP. :-)

-- 
Greg Ewing, Computer Science Dept, +--------------------------------------+
University of Canterbury,	   | A citizen of NewZealandCorp, a	  |
Christchurch, New Zealand	   | wholly-owned subsidiary of USA Inc.  |
greg.ewing at canterbury.ac.nz	   +--------------------------------------+


More information about the Python-Dev mailing list