[issue24739] allow argparse.FileType to accept newline argument

2021-10-25 Thread paul j3


paul j3  added the comment:

Adding `newline` to `FileType` requires modifying both the `__init__` and 
`__call__` methods.  That's nearly the whole class.  I'd copy and edit, and 
forget about subclassing.

--

___
Python tracker 

___
___
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue24739] allow argparse.FileType to accept newline argument

2021-10-25 Thread Mitar


Mitar  added the comment:

I think the issue is that it is hard to subclass it. Ideally, call to open 
would be made through a new _open method which would then call it, and one 
could easily subclass that method if/when needed.

--
nosy: +mitar

___
Python tracker 

___
___
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue24739] allow argparse.FileType to accept newline argument

2017-04-19 Thread Berker Peksag

Berker Peksag added the comment:

I agree with paul j3. It would be nice to keep the current FileType API as is. 
The argparse documentation already encourages people to write their own custom 
types and I think this is a good use case for following the advice.

Thanks for the report!

--
nosy: +berker.peksag
resolution:  -> rejected
stage:  -> resolved
status: open -> closed
versions: +Python 3.7 -Python 3.2, Python 3.3, Python 3.4, Python 3.5, Python 
3.6

___
Python tracker 

___
___
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue24739] allow argparse.FileType to accept newline argument

2017-03-27 Thread AlbertZhuang

Changes by AlbertZhuang :


--
pull_requests: +750

___
Python tracker 

___
___
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue24739] allow argparse.FileType to accept newline argument

2015-08-03 Thread paul j3

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 

___
___
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue24739] allow argparse.FileType to accept newline argument

2015-07-27 Thread Gary Peck

New submission from Gary Peck:

argparse.FileType should support a "newline" argument that corresponds to the 
"newline" parameter to open(). In addition to more closely mirroring the open() 
API, this is also needed to properly use argparse.FileType with csv.reader() or 
csv.writer() (which require the file being passed in to have been opened with 
newline='').

--
components: Library (Lib)
messages: 247497
nosy: garyp
priority: normal
severity: normal
status: open
title: allow argparse.FileType to accept newline argument
type: enhancement
versions: Python 3.2, Python 3.3, Python 3.4, Python 3.5, Python 3.6

___
Python tracker 

___
___
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com