Verbosity Check Style

brianc at temple.edu brianc at temple.edu
Thu Aug 12 11:23:49 EDT 2004


I would like to get people's views on the best way to
implement verbosity (or any command-line option) into python
scripts. 

The three styles I'm wrestling with are:

def func():
    #do stuff
    if VERBOSE:
        print #something useful to know if wanted

or...

if VERBOSE:
    def func():
        #do stuff
        print #something useful to know if wanted
else:
    def func():
        #do stuff

or...

def vfunc():
    #do stuff
    print #something useful to know if wanted
def func():
    #do stuff
if VERBOSE:
    func=vfunc

The former has the benefit of readability. The latter two
examples the benefit of being faster. 

Is there any other great pythonic ways to do this? I'd like to
sample the smorgusborg of styles this list usually offers.

Thanks in advance,
Brian

PS. I'd like to extend an extra thanks to all the large
brain's in jars here. I'm just finishing a summer internship
at a Pharmaceutical Company customizing/optimizing
scripts/programs to do very high end computational chemistry.
(Why I'm a bit obsessed with speed) I have absolutely no
chemistry background and before I started only a year doing
python for small data processing challenges. Through being
able to read this list fairly constantly I've been able to
make such a big splash here (things that used to take days,
now take minutes) in my small amount of time that they'd like
to give me a laptop to keep me on as a contractor during the
school year. Thank you all so very much for giving a 19 year
old a bright future and a way to pay for college.



More information about the Python-list mailing list