What makes an iterator an iterator?
Steve Holden
steve at holdenweb.com
Thu Apr 19 22:04:36 EDT 2007
7stud wrote:
> On Apr 19, 5:37 am, Steve Holden <s... at holdenweb.com> wrote:
>> It's nothing to do with the name lookup. Alex mentioned that to remind
>> us that the magic "double-under" names are looked up on the type rather
>> than the instance...
>
> P.next()
>
> vs.
>
> type(P).next()
>
> Where is the "double-under" name?
>
Try and stick with the main party. Here is the exact exchange (between
Steven D'Aprano and Alex) to which I referred:
> Steven D'Aprano <steve at REMOVEME.cybersource.com.au> wrote:
>
>> > I thought that an iterator was any object that follows the iterator
>> > protocol, that is, it has a next() method and an __iter__() method.
>
> The special methods need to be on the type -- having attributes of those
> names on the instance doesn't help (applies to all special methods in
> the normal, aka newstyle, object model; legacy, aka classic, classes,
> work by slightly different and not entirely self-consistent semantics).
So if you have a beef, it would appear to be with Alex?
regards
Steve
--
Steve Holden +44 150 684 7255 +1 800 494 3119
Holden Web LLC/Ltd http://www.holdenweb.com
Skype: holdenweb http://del.icio.us/steve.holden
Recent Ramblings http://holdenweb.blogspot.com
More information about the Python-list
mailing list