Error with iterators

472 views
Skip to first unread message

Salvatore DI DIO

unread,
Jul 17, 2015, 7:01:12 AM7/17/15
to bry...@googlegroups.com
Hello,

Am i missing something ?

Regards

Brython 3.2.0 on Netscape 5.0 (Windows)
>>> iter
<built-in function iter>
>>> x = iter([1, 2, 3])
>>> x.next()
Traceback (most recent call last):
  module __main__ line 2
    qs_lang, language = header.show('../')
  module __main__17 line 141
    traceback.print_exc()
  module exec_64 line 1
    x.next()
AttributeError: 'list_iterator' object has no attribute 'next'
>>>

Kiko

unread,
Jul 17, 2015, 7:07:55 AM7/17/15
to bry...@googlegroups.com
>>

--

I think your syntax is Python 2. On Python 3 you can use:
next(x)
x.__next__()
 

You received this message because you are subscribed to the Google Groups "brython" group.
To unsubscribe from this group and stop receiving emails from it, send an email to brython+u...@googlegroups.com.
To post to this group, send email to bry...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/brython/b4cc6ac9-6389-425d-8bd9-29ababf9b065%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Salvatore DI DIO

unread,
Jul 17, 2015, 8:17:48 AM7/17/15
to bry...@googlegroups.com
Thank you Kiko

I was sure I read 'nex't when using the dir(x) command.
Eyes see what they want to see :-)

Salvatore DI DIO

unread,
Jul 17, 2015, 8:20:05 AM7/17/15
to bry...@googlegroups.com
I have just read on stackoverflow that one can use next(x)


Brython 3.2.0 on Netscape 5.0 (Windows)
>>> s = iter([5,5,6])
>>> next(s)
5

>>>

Le vendredi 17 juillet 2015 13:07:55 UTC+2, kiko (on pybonacci) a écrit :
Reply all
Reply to author
Forward
0 new messages