![]() |
Available news archives:
comp.lang.tcl
-
comp.lang.python
-
comp.security.firewalls
-
sci.crypt -
comp.lang.php -
comp.lang.javascript
|
|
comp.lang.python archiveRe: Need help removing list elements.
From: John Machin <sjmachin@lexicon.net>
Date: Sat Apr 29 2006 - 23:47:02 CEST
On 30/04/2006 12:22 AM, Max Erickson wrote:
If you are hell-bent on conditionally deleting items from a list in
for i in xrange(len(alist)-1, -1, -1):
> Creating a new list and appending the elements you want to keep avoids
Call me crazy, but I wouldn't open the file in BINARY mode :-)
> if line != ""]
For a modicum of extra effort, the condition "if line.strip()" throws
However I don't see the point of creating a list of lines, then throwing
The OP might be even better advised to (read the source of, use) an
Hope some of this helps,
|