Message247939
| Author |
paul.j3 |
| Recipients |
garyp, paul.j3 |
| Date |
2015年08月03日.17:03:35 |
| SpamBayes Score |
-1.0 |
| Marked as misclassified |
Yes |
| Message-id |
<1438621415.27.0.556448044451.issue24739@psf.upfronthosting.co.za> |
| In-reply-to |
| Content |
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. |
|
History
|
|---|
| 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 |
|