Request for feedback on my first Python program

Ganesan R rganesan at myrealbox.com
Fri May 30 05:50:54 EDT 2003


>>>>> "Max" == Max M <maxm at mxm.dk> writes:

> Ganesan R wrote:
>> readlines() will slurp in the whole file into memory.

> That is most likely not a problem in this case.

Right. Others already pointed out that the trailing new line was the
problem. 

>> for line in file:
>> if line and line.startswith("#"):
>> line.rstrip()      # strip \n and other white space

> The spec said where the first non-whitespace character is #. This
> means that there can be whitespace characters before the #.

> So it is better to strip first to remove those.

You're right. 

> Also strip() returns a string, it dosn't mutate the one you are in:

Right again. Thanks. Moral: don't post untested code to the list (as if I am
going to follow that one :-)

Ganesan

-- 
Ganesan R (rganesan at debian dot org) | http://www.debian.org/~rganesan/
1024D/5D8C12EA, fingerprint F361 84F1 8D82 32E7 1832  6798 15E0 02BA 5D8C 12EA




More information about the Python-list mailing list