help with comparison
John Machin
sjmachin at lexicon.net
Wed Nov 19 23:28:08 EST 2008
On Nov 20, 2:21 pm, tekion <tek... at gmail.com> wrote:
> 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) :
Do some elementary debugging; insert here:
print type(zipfile), repr(zipfile)
print type(1), repr(1)
then work out for yourself what you should do next.
> 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