[Tutor] Newby Linux Program review + help with regular expressions
Alan Gauld
alan.gauld at btinternet.com
Mon Mar 9 23:28:19 CET 2009
"David" <david at abbottdavid.com> wrote
> and compare with others, ask for help etc. Am I using the subrocess
> module too much because I am comfortable with the commands? Should I
> just write this type of program in bash.
Personally I'd use bash for this kind of thing.
If you wanted to post process the report then I'd use Python.
You could do a faitr bit with Python commands, especially the
functions in the os module, but since the scripts already exist you
might as well use them.
One thing though, you could use triple quoted strings and string
formatting more:
fobj.write(nick)
fobj.write(" \n")
fobj.write(make)
fobj.write(" \n")
fobj.write(model)
fobj.write(" \n")
fobj.close()Could be:
fobj.write("%s\n%s\n%s\n" % (nick,make,model) )
> #This is a comment with 5 spaces
you can use the lstrip() methjod of a string:
if line.lstrip().startswith('#'):
isComment = True
HTH,
--
Alan G
Author of the Learn to Program web site
http://www.alan-g.me.uk/
More information about the Tutor
mailing list