[Pyparsing] Re: empty lines and restOfLine comments
Brought to you by:
ptmcg
From: Robert P. <rob...@gm...> - 2005-03-31 23:49:06
|
Here is an update: I now use the following, which works fine as long as there are no "=" characters in the comment lines: chars = alphanums + "_" + "." + "\\" assignment = Word(chars) + Literal("=").suppress() + Word(chars) cfgFile = file("cfg-snippet") cfgData = "".join(cfgFile.readlines()) cfgFile.close() assignments = dict([t for t,s,e in assignment.scanString(cfgData)]) print assignments['floin_file'] |