array next pointer

Andre Engels andreengels at gmail.com
Tue Mar 17 12:26:13 CET 2009


On Tue, Mar 17, 2009 at 12:24 PM, Andre Engels <andreengels at gmail.com> wrote:
> On Tue, Mar 17, 2009 at 12:12 PM, Anjanesh Lekshminarayanan
> <mail at anjanesh.net> wrote:
>>>>> a = ['cat','dog','elephant']
>>>>> a.next()
>> Traceback (most recent call last):
>>  File "<stdin>", line 1, in <module>
>> AttributeError: 'list' object has no attribute 'next'
>>>>>
>> Is there something that imtates PHP's next() ? (http://php.net/next)
>
>>>> b = a.__iter__()
>>>> b.next()
> 1
>>>> b.next()
> 2

That should of course be:

>>> b = a.__iter__()
>>> b.next()
'cat'
>>> b.next()
'dog'

I had copied a bit too literal from my own attempt...

-- 
André Engels, andreengels at gmail.com



More information about the Python-list mailing list