Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
Groups > comp.lang.python > #63818 > unrolled thread
| Started by | Laszlo Nagy <gandalf@shopzeus.com> |
|---|---|
| First post | 2014-01-13 10:00 +0100 |
| Last post | 2014-01-13 10:00 +0100 |
| Articles | 1 — 1 participant |
Back to article view | Back to comp.lang.python
This discussion starts older than the indexed window; earlier articles aren't shown. The article labeled Started by
below is the oldest one visible, not the original post.
Re: L[:] Laszlo Nagy <gandalf@shopzeus.com> - 2014-01-13 10:00 +0100
| From | Laszlo Nagy <gandalf@shopzeus.com> |
|---|---|
| Date | 2014-01-13 10:00 +0100 |
| Subject | Re: L[:] |
| Message-ID | <mailman.5398.1389604172.18130.python-list@python.org> |
> Unless L is aliased, this is silly code.
There is another use case. If you intend to modify a list within a for
loop that goes over the same list, then you need to iterate over a copy.
And this cannot be called an "alias" because it has no name:
for idx,item in enumerate(L[:]):
# do something with L here, including modification
--
This message has been scanned for viruses and
dangerous content by MailScanner, and is
believed to be clean.
Back to top | Article view | comp.lang.python
csiph-web