Question: Python's argparse lets me define argument names containing a dot in the name. But how can I access these ?

```
import argparse

parser = argparse.ArgumentParser()
parser.add_argument("inputfile.txt")
parser.add_argument("outputfile.txt")

args = parser.parse_args(['hello', 'world'])

# now args is:
# Namespace(inputfile.txt='hello', outputfile.txt='world')

# and this does not work
print(args.inputfile.txt)
>>> AttributeError: 'Namespace' object has no attribute 'inputfile'

```

Obviously attribute names can be created with a dot in their name but how can these be accessed ?

Edit:
My goal was to let argparse display the inputfile.txt name (e.g. with --help) but call the attribute "inputfile".

After trying some of the suggestions the easiest way to accomplish this is using the metavar option:

```
parser.add_argument("inputfile", metavar="inputfile.txt")

```

Answer: 
Why not use [FileType](https://docs.python.org/2.7/library/argparse.html#filetype-objects) objects instead?

```
>>> import argparse
>>>
>>> parser = argparse.ArgumentParser()
>>> parser.add_argument('--infile', type=argparse.FileType('r'))
_StoreAction(option_strings=['--infile'], dest='infile', nargs=None, const=None, default=None, type=FileType('r'), choices=None, help=None, metavar=None)
>>> parser.add_argument('--outfile', type=argparse.FileType('w'))
_StoreAction(option_strings=['--outfile'], dest='outfile', nargs=None, const=None, default=None, type=FileType('w'), choices=None, help=None, metavar=None)
>>> parser.parse_args(['--infile', 'input.txt', '--outfile', 'output.txt'])
Namespace(infile=<open file 'input.txt', mode 'r' at 0x100f99e40>, outfile=<open file 'output.txt', mode 'w' at 0x100f99ed0>)

```
I strongly recommend you to refactor your code to change the argument name.  

But, if you won't or can't, this will do the job:

```
args.__dict__['inputfile.txt']

```