hey all
I am trying to write a pogram with arguments and options

I want to call it this way:

python myScript.py -c -f 'C:/Temp/my_file.txt'


python myScript.py -u -f 'C:/Temp/my_file.txt'

where [-f filename] is mandatory
and exactly one of -c or -u should be there

In other words,
Arguments = [-c -u] -f filename (I prefer to drop the -f if possible)

The script copies the file in a destination folder, which is different according to the -c or -u option.

I couldn't write this down.
I used the getOpt module, then the optParse one. I did the [-c -u] part with getopt, but I couldn't add the filename part and validate whether the argument is there..

Please I need some help on this.
I assume it is very easy for those who are familiar with python, but I searched a lot and the documentation about this is very poor, especially when I want to use an option without argument..


A few print statements should simplify things

import sys

##python ./myScript.py -b -e 'test_name'
print sys.argv, "\n"
for j in range(1, len(sys.argv)):
   print " arg", j, sys.argv[j]
   if not sys.argv[j].startswith("-"):
      print "     name is", sys.argv[j]
if (" -c" not in sys.argv) and (" -u" not in sys.argv):
   print "\n no -c or -u arg found"
if not file_found:
   print "\n no file name arg found"