Message247939
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. |
|
Date |
User |
Action |
Args |
2015-08-03 17:03:35 | paul.j3 | set | recipients:
+ paul.j3, garyp |
2015-08-03 17:03:35 | paul.j3 | set | messageid: <1438621415.27.0.556448044451.issue24739@psf.upfronthosting.co.za> |
2015-08-03 17:03:35 | paul.j3 | link | issue24739 messages |
2015-08-03 17:03:35 | paul.j3 | create | |
|