Evaluate coding and style
jeanmichel at sequans.com
Fri Sep 25 13:46:49 CEST 2009
Rhodri James wrote:
> On Thu, 24 Sep 2009 21:11:36 +0100, Brown, Rodrick
> <rodrick.brown at citi.com> wrote:
>> I recently started playing with Python about 3 days now (Ex Perl guy)
>> and wanted some input on style and structure of what I'm doing before
>> I really start picking up some bad habits here is a simple test tool
>> I wrote to validate home dirs on my system.
> Ethan's made some good points. Here are a couple more.
>> fh = open(filename)
>> except IOError:
>> print "No such filename: %s" % (filename)
It's is usually a bad idea to loose information when giving feedback to
fh = open(filename)
except IOError, exception:
print "Error openning %s : " % (filename, exception)
In general, if you want to improve your coding style/rules, read PEP 8
and this page :
This is a must read (yet you still can disagree).
fh = open(filename) would become
fileHandler = open(fileName)
Much nicer to read :o)
These are just suggestions, cheers.
More information about the Python-list