[issue19959] argparse.FileType does not expand tilde "~"

paul j3 report at bugs.python.org
Thu Dec 19 06:46:30 CET 2013


paul j3 added the comment:

Normally the unix shell takes care of this expansion.  If I call a simple script that prints sys.argv and runs a simple parser, I get:

    2135:~/mypy$ python2.7 filetypetest.py ~/mypy/test.txt
    ['filetypetest.py', '/home/paul/mypy/test.txt']
    Namespace(file=<open file '/home/paul/mypy/test.txt', mode 'r'...)

I have to quote the argument '~/mypy/test.blog' to bypass this expansion.

This is under Linux (bash).  Is Windows or Mac different?

My impression is that `FileType` has been provided as an example of a custom `type`, as opposed to a comprehensive file handler.  But I can't quote a developer on this.  

http://bugs.python.org/issue13824 is a bug report that worries that 'argparse.FileType opens a file and never closes it'.  There are some comments there about whether it is appropriate to expand on the capabilities of FileType.

----------
nosy: +paul.j3

_______________________________________
Python tracker <report at bugs.python.org>
<http://bugs.python.org/issue19959>
_______________________________________


More information about the Python-bugs-list mailing list