# in all examples below, we have to allow for '--' args
# which are represented as '-' in the pattern
and I can't figure it out. I am spending time to understand this piece of code so that I can make use of it. It sounds like special treatments are made to those pattern strings like '(-*A[A-]*)' because single dash and double dash are both represented as - in the the arg_string_pattern. Am I wrong? I understand the basic behind the scene -- an arg_string_pattern is built from the actual arg_strings and matched against the pattern built from nargs of an action. But like 'A' and 'O', dash can appear as many time as it likes because user can gave you -- -- - -, which became ---- in the arg_string_pattern. I can't see any relationship between this fact and the fact that double dash is represented as single dash. But the comments somehow implied such relationship.
So what information this piece of comment want to convey? Help!
https://github.com/ThomasWaldmann/argparse/blob/67f3ce3c9ad8442d1d4c43724ced5b9ac65faf77/argparse.py#L2177-L2180 The comment below the
_get_nargs_pattern
saysand I can't figure it out. I am spending time to understand this piece of code so that I can make use of it. It sounds like special treatments are made to those pattern strings like
'(-*A[A-]*)'
because single dash and double dash are both represented as-
in the thearg_string_pattern
. Am I wrong? I understand the basic behind the scene -- anarg_string_pattern
is built from the actualarg_strings
and matched against the pattern built fromnargs
of anaction
. But like'A'
and'O'
, dash can appear as many time as it likes because user can gave you-- -- - -
, which became----
in thearg_string_pattern
. I can't see any relationship between this fact and the fact that double dash is represented as single dash. But the comments somehow implied such relationship.So what information this piece of comment want to convey? Help!