Il giorno mercoledì 31 maggio 2017 00:18:40 UTC+2, guillaum...@giome.fr ha scritto: > Hi Beppe ! > > There are some powerful tools in the standard *itertools* module, you > should have a look at it :) > https://docs.python.org/3/library/itertools.html > > This is what I would do to cycle over you iterable without making > several copies of it. > > ``` > from itertools import islice, chain > > def cycle_once(iterable, start): > return chain(islice(iterable, start, None), islice(iterable, start)) > > my_iterable = ('A','B','C','D','E','F','G','H') > > for e in cycle_once(my_iterable, 2): > print(i) > ``` for e in cycle_once(my_iterable, 2): print(e)
perfect, thanks > > Ps: I am pretty new to how a mailing list works. If I answered the wrong > way, do not hesitate to tell me :) -- https://mail.python.org/mailman/listinfo/python-list