array next pointer
Andre Engels
andreengels at gmail.com
Tue Mar 17 07:24:40 EDT 2009
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
However, in many cases the more Pythonic way of working will be to use
a for-loop (which is like a foreach-loop in PHP and other languages).
--
André Engels, andreengels at gmail.com
More information about the Python-list
mailing list