Message172875
It is safe to modify a sequence during iteration if it's size not increased.
>>> words = ['cat', 'window', 'defenestrate']
>>> for i, w in enumerate(words):
... if len(w) > 6:
... words[i] = w[:5] + '…'
...
>>> words
['cat', 'window', 'defen…'] |
|
Date |
User |
Action |
Args |
2012-10-14 11:24:05 | serhiy.storchaka | set | recipients:
+ serhiy.storchaka, chris.jerdonek, docs@python, Ian |
2012-10-14 11:24:05 | serhiy.storchaka | set | messageid: <1350213845.32.0.702999618177.issue16225@psf.upfronthosting.co.za> |
2012-10-14 11:24:05 | serhiy.storchaka | link | issue16225 messages |
2012-10-14 11:24:05 | serhiy.storchaka | create | |
|