help with comparison

tekion tekion at gmail.com
Wed Nov 19 22:21:46 EST 2008


Hi,
Could some one take a look at the below code snipet which keep
failing:

import optparse
p = optparse.OptionParser(description="script to do stuff",
prog="myscript.py", ....)
p.add_option("-c" "--compress", help="0 is noncompress")
function1(options.compress)

here's what the what function definition looks like:
function1(zipfile) :
if (zipfile == 1):
   do stuff here with for compress file
else
   do stuff here

when I call the script "myscript.py 1", the above test keeps falling
to the else clause.  I am thinking the object zipfile is not the same
as "1". Any thoughts as how I should test if the argument being pass
in and parse by optparse is 1 or "0"?  Thanks.



More information about the Python-list mailing list