You are using the wrong character:
>>> parser = argparse.ArgumentParser(description='This program downloads webcam images')
>>> parser.add_argument('‐startdate', type=str, help='startdate given as:dd.mm.YYYY')
_StoreAction(option_strings=[], dest='\xe2\x80\x90startdate', nargs=None, const=None, default=None, type=<type 'str'>, choices=None, help='startdate given as:dd.mm.YYYY', metavar=None)
Note the dest value there! That's UTF-8 for U+2010 HYPHEN; use an ASCII - minus character instead. Because the string doesn't start with parser.prefix_chars, it isn't even recognised as an optional argument, but rather as positional. As a result, option_strings is also empty. The help output tells you this too:
>>> parser.print_help()
usage: [-h] ‐startdate
This program downloads webcam images
positional arguments:
‐startdate startdate given as:dd.mm.YYYY
optional arguments:
-h, --help show this help message and exit
It is a positional (required) argument here.
Generally speaking, make sure you are not using a word processor to write code; most likely your simple ASCII - dash was replaced by your editor to a fancy ‐ HYPHEN character (note how it is rendered shorter). Such editors will also replace quotes and other punctuation with more styled versions.
If I use a regular ASCII minus character things work just fine:
>>> parser = argparse.ArgumentParser(description='This program downloads webcam images')
>>> parser.add_argument('-startdate', type=str, help='startdate given as:dd.mm.YYYY')
_StoreAction(option_strings=['-startdate'], dest='startdate', nargs=None, const=None, default=None, type=<type 'str'>, choices=None, help='startdate given as:dd.mm.YYYY', metavar=None)
>>> parser.print_help()
usage: [-h] [-startdate STARTDATE]
This program downloads webcam images
optional arguments:
-h, --help show this help message and exit
-startdate STARTDATE startdate given as:dd.mm.YYYY
You are using the wrong character:
>>> parser = argparse.ArgumentParser(description='This program downloads webcam images')
>>> parser.add_argument('‐startdate', type=str, help='startdate given as:dd.mm.YYYY')
_StoreAction(option_strings=[], dest='\xe2\x80\x90startdate', nargs=None, const=None, default=None, type=<type 'str'>, choices=None, help='startdate given as:dd.mm.YYYY', metavar=None)
Note the dest value there! That's UTF-8 for U+2010 HYPHEN; use an ASCII - minus character instead.
Generally speaking, make sure you are not using a word processor to write code; most likely your simple ASCII - dash was replaced by your editor to a fancy ‐ HYPHEN character (note how it is rendered shorter). Such editors will also replace quotes and other punctuation with more styled versions.
If I use a regular ASCII minus character things work just fine:
>>> parser = argparse.ArgumentParser(description='This program downloads webcam images')
>>> parser.add_argument('-startdate', type=str, help='startdate given as:dd.mm.YYYY')
_StoreAction(option_strings=['-startdate'], dest='startdate', nargs=None, const=None, default=None, type=<type 'str'>, choices=None, help='startdate given as:dd.mm.YYYY', metavar=None)
>>> parser.print_help()
usage: [-h] [-startdate STARTDATE]
This program downloads webcam images
optional arguments:
-h, --help show this help message and exit
-startdate STARTDATE startdate given as:dd.mm.YYYY
You are using the wrong character:
>>> parser = argparse.ArgumentParser(description='This program downloads webcam images')
>>> parser.add_argument('‐startdate', type=str, help='startdate given as:dd.mm.YYYY')
_StoreAction(option_strings=[], dest='\xe2\x80\x90startdate', nargs=None, const=None, default=None, type=<type 'str'>, choices=None, help='startdate given as:dd.mm.YYYY', metavar=None)
Note the dest value there! That's UTF-8 for U+2010 HYPHEN; use an ASCII - minus character instead. Because the string doesn't start with parser.prefix_chars, it isn't even recognised as an optional argument, but rather as positional. As a result, option_strings is also empty. The help output tells you this too:
>>> parser.print_help()
usage: [-h] ‐startdate
This program downloads webcam images
positional arguments:
‐startdate startdate given as:dd.mm.YYYY
optional arguments:
-h, --help show this help message and exit
It is a positional (required) argument here.
Generally speaking, make sure you are not using a word processor to write code; most likely your simple ASCII - dash was replaced by your editor to a fancy ‐ HYPHEN character (note how it is rendered shorter). Such editors will also replace quotes and other punctuation with more styled versions.
If I use a regular ASCII minus character things work just fine:
>>> parser = argparse.ArgumentParser(description='This program downloads webcam images')
>>> parser.add_argument('-startdate', type=str, help='startdate given as:dd.mm.YYYY')
_StoreAction(option_strings=['-startdate'], dest='startdate', nargs=None, const=None, default=None, type=<type 'str'>, choices=None, help='startdate given as:dd.mm.YYYY', metavar=None)
>>> parser.print_help()
usage: [-h] [-startdate STARTDATE]
This program downloads webcam images
optional arguments:
-h, --help show this help message and exit
-startdate STARTDATE startdate given as:dd.mm.YYYY
You are using the wrong character:
>>> parser = argparse.ArgumentParser(description='This program downloads webcam images')
>>> parser.add_argument('‐startdate', type=str, help='startdate given as:dd.mm.YYYY')
_StoreAction(option_strings=[], dest='\xe2\x80\x90startdate', nargs=None, const=None, default=None, type=<type 'str'>, choices=None, help='startdate given as:dd.mm.YYYY', metavar=None)
Note the dest value there! That's UTF-8 for U+2010 HYPHEN; use an ASCII - minus character instead.
Generally speaking, make sure you are not using a word processor to write code; most likely your simple ASCII - dash was replaced by your editor to a fancy ‐ HYPHEN character (note how it is rendered shorter). Such editors will also replace quotes and other punctuation with more styled versions.
If I use a regular ASCII minus character things work just fine:
>>> parser = argparse.ArgumentParser(description='This program downloads webcam images')
>>> parser.add_argument('-startdate', type=str, help='startdate given as:dd.mm.YYYY')
_StoreAction(option_strings=['-startdate'], dest='startdate', nargs=None, const=None, default=None, type=<type 'str'>, choices=None, help='startdate given as:dd.mm.YYYY', metavar=None)
>>> parser.print_help()
usage: [-h] [-startdate STARTDATE]
This program downloads webcam images
optional arguments:
-h, --help show this help message and exit
-startdate STARTDATE startdate given as:dd.mm.YYYY