len(sys.argv) in (3,4)
bruno modulix
onurb at xiludom.gro
Thu Aug 11 11:53:58 EDT 2005
Daniel Schüle wrote:
> Hello
>
> I wrote a simple module, which is also supposed to be used as standalone
> program
> after considering how to avoid multiple if's I came up with this idea
>
> if __name__ == "__main__":
> if len(sys.argv) not in (3,4):
> print "usage: prog arg1 argv2 [-x]"
> # etc ...
>
> while develeoping I had my interpeter running and reloaded module
> now since I am ready, I wanted to run it from cmd windows shell
> but it always prints "usage ..."
> I added print len(sys.arg) and it prints 1 though I am provinding more
> than 1 value
>
>
> C:\pool\vhd2h\python>vhd2h.py vhd.vhd vhd.h -o
> 1
> usage: vhd2h.py vhdlFile hFile [-o]
>
> Someone got an idea what may be wrong?
Nope. But since you're running this on a very peculiar OS, I just can
guess that this very peculiar OS consider all args to be one same string...
Try this:
if __name__ == "__main__":
for num, arg in enumerate(sys.argv):
print "arg %d is %s" % (num, arg)
This should art least give you some hints...
BTW, isn't the DOS syntax for command line args something like :
> myprog /arg1 /arg2
???
--
bruno desthuilliers
python -c "print '@'.join(['.'.join([w[::-1] for w in p.split('.')]) for
p in 'onurb at xiludom.gro'.split('@')])"
More information about the Python-list
mailing list