I want to use reserved keyword \"from\" as the name of variable.
I have it in my arguments parser:
parser.add_argument(\"--from\")
args = parser.parse_ar
You can use getattr()
to access the attribute:
print(getattr(args, 'from'))
However, in argparse
you can have the command-line option --from
without having to have the attribute from
by using the dest option to specify an alternative name to use:
parser.add_argument('--from', dest='from_')
# ...
args = parser.parse_args()
print(args.from_)