T
Tool69
Hi,
Let say I've got a simple list like my_list = [ 'a', ',b', 'c' ].
We can have an iterator from it by k = iter( my_list), then we can
access each of her (his ?) element by k.next(), etc.
Now, I just wanted k to have the following cyclic behaviour (without
rising the ) :
'b'
etc.
I've tried something like this to have a cyclic iterator without
sucess:
def iterate_mylist(my_list):
k = len((my_list)
i=0
while i <= k :
yield my_list
i += 1
i = 0
yield my_list[0]
I missed something, but I don't know what exactly.
Thanks.
Let say I've got a simple list like my_list = [ 'a', ',b', 'c' ].
We can have an iterator from it by k = iter( my_list), then we can
access each of her (his ?) element by k.next(), etc.
Now, I just wanted k to have the following cyclic behaviour (without
rising the ) :
'b'
etc.
I've tried something like this to have a cyclic iterator without
sucess:
def iterate_mylist(my_list):
k = len((my_list)
i=0
while i <= k :
yield my_list
i += 1
i = 0
yield my_list[0]
I missed something, but I don't know what exactly.
Thanks.