perl chomp equivalent in python?
Fred Gansevles
fred at gansevles.ourfamily.com
Wed Mar 8 16:02:32 EST 2000
More information about the Python-list mailing list
Wed Mar 8 16:02:32 EST 2000
- Previous message (by thread): emacs can't find python-mode
- Next message (by thread): perl chomp equivalent in python?
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]
François Pinard wrote: > > Fred Gansevles <gansevle at cs.utwente.nl> writes: > > > for line in string.split (open (file).read(), '\n'): > > .... > > It looks like a good idea. You usually have an empty line at end? > > -- > François Pinard http://www.iro.umontreal.ca/~pinard Usually my code skips all empty lines, after the '#' is removed from the line Allowing comment in input files is IMO usefull (but others may disagree) Since I usually skip empty lines, my line-parsing code looks like: for line in string.split (open (file).read (), '\n'): line = string.split (line, '#')[0] if not line: continue # insert 'real' code here ... Now it doesn't matter if the last line is empty or not
- Previous message (by thread): emacs can't find python-mode
- Next message (by thread): perl chomp equivalent in python?
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]
More information about the Python-list mailing list