G
grocery_stocker
Given the following
[cdalten@localhost ~]$ python
Python 2.4.3 (#1, Oct 1 2006, 18:00:19)
[GCC 4.1.1 20060928 (Red Hat 4.1.1-28)] on linux2
Type "help", "copyright", "credits" or "license" for more information..... mylist = range(3)
.... for i in mylist:
.... yield i*i
........ i = gen.next()
.... print i
....
0
1
4
Traceback (most recent call last):
File "<stdin>", line 2, in ?
StopIteration
I thought the 'for' in counter() was supposed to catch StopIteration.
Ie, I thought that something like
.... for i in mylist:
.... yield i*i
Got translated to something like.... while True:
.... do some stuff
.... except StopIteration:
.... pass
....
[cdalten@localhost ~]$ python
Python 2.4.3 (#1, Oct 1 2006, 18:00:19)
[GCC 4.1.1 20060928 (Red Hat 4.1.1-28)] on linux2
Type "help", "copyright", "credits" or "license" for more information..... mylist = range(3)
.... for i in mylist:
.... yield i*i
........ i = gen.next()
.... print i
....
0
1
4
Traceback (most recent call last):
File "<stdin>", line 2, in ?
StopIteration
I thought the 'for' in counter() was supposed to catch StopIteration.
Ie, I thought that something like
.... for i in mylist:
.... yield i*i
Got translated to something like.... while True:
.... do some stuff
.... except StopIteration:
.... pass
....