Ignoring comments - Parsing input file
Yigal Duppen
yduppen at xs4all.nl
Sat Oct 12 05:32:12 EDT 2002
More information about the Python-list mailing list
Sat Oct 12 05:32:12 EDT 2002
- Previous message (by thread): Ignoring comments - Parsing input file
- Next message (by thread): Ignoring comments - Parsing input file
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]
Simon Faulkner wrote:
> I am writing a script which reads it's input from a text file
>
> What is the easiest way to make it ignore lines that start with # or
> blank lines?
# python2.2 code
# untested :-)
for line in inputfile:
if not line.strip():
# blank line, ignore
continue
if line.startswith("#"):
# comment line, ignore
continue
# line is not empty, not a comment
process_line(line)
Hope this helps,
YDD
--
http://www.xs4all.nl/~yduppen
- Previous message (by thread): Ignoring comments - Parsing input file
- Next message (by thread): Ignoring comments - Parsing input file
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]
More information about the Python-list mailing list