paul j3 added the comment:
argparse.FileType serves 2 purposes
- handling filenames for simple quick shell-like scripts
- as a model for custom 'types', specifically one that uses a class to generate
the desired type callable.
Other bug-issues show that it hasn't aged well. It doesn't work nicely with
the newer open/close context paradigm. It needs changes to handle 'rb' and
'wb' modes.
I suppose it could be modified to accept the full range of parameters that the
modern 'open' takes:
open(file, mode='r', buffering=-1, encoding=None,
errors=None, newline=None, closefd=True, opener=None)
either explicitly, or as a pass through **kwargs.
But it is also something that you could easily subclass or modify for your own
purposes.
Or just accept the filenames as strings, and do your own open/close after
parsing. This gives you more control over when and how the files are opened.
----------
nosy: +paul.j3
_______________________________________
Python tracker <[email protected]>
<http://bugs.python.org/issue24739>
_______________________________________
_______________________________________________
Python-bugs-list mailing list
Unsubscribe:
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com