python style question around reading small files -
What is the most dragon way of reading in the named file, strip rows which are empty, are only spaces, or # ago In the form of letters, and then process the remaining lines? Suppose that all fit easily in memory.
Note: It is not difficult to do this - what I am asking is the path of most dragon. I am writing lots of ruby and java and lost my experience.
Here is a stromman:
file_lines = [line.strip () for open row (Config_file, 'r'). Readlines () if LAN (line.strip ()) 0] file_lines for line: if line [0] == '#': Continue # Whatever the line with the line here.
I am interested in divorce but not at the cost of being difficult to read.
line = [R for open (thefile) if not r.isspace ( ) And r [0]! The best way to test the method of string is if a string is completely white space - such as < No need for contortions for code> len (r.strip ()) = = 0
(ech; -).
Comments
Post a Comment