This issue tracker has been migrated to GitHub, and is currently read-only.
For more information, see the GitHub FAQs in the Python's Developer Guide.

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:35paul.j3setrecipients: + paul.j3, garyp
2015-08-03 17:03:35paul.j3setmessageid: <1438621415.27.0.556448044451.issue24739@psf.upfronthosting.co.za>
2015-08-03 17:03:35paul.j3linkissue24739 messages
2015-08-03 17:03:35paul.j3create