iterating lists
Steven D'Aprano
steve at REMOVE-THIS-cybersource.com.au
Sat Jan 23 12:44:22 EST 2010
More information about the Python-list mailing list
Sat Jan 23 12:44:22 EST 2010
- Previous message (by thread): iterating lists
- Next message (by thread): iterating lists
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]
On Sat, 23 Jan 2010 18:29:33 +0100, Roel Schroeven wrote:
>> for w in l1[:]: #use copy of l1 for iteration
>> print(l1.pop()) #decomposite list
>
> I would prefer:
>
> while l1:
> print(l1.pop())
I would prefer:
for x in reversed(l1):
print(x)
l1[:] = []
And garbage dispose of the entire list in one go, instead of an item at a
time.
--
Steven
- Previous message (by thread): iterating lists
- Next message (by thread): iterating lists
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]
More information about the Python-list mailing list