paul j3 <ajipa...@gmail.com> added the comment:

The pathlib.Path is new since I paid much attention to os matters (I cut my 
teeth on py2.5).

Off hand it looks like the user could

    import pathlib
    parser.add_argument('-p', type=pathlib.Path)

to convert a string into a Path object.

A custom type function could call this, and apply any desired methods before 
returning the Path object. But that should be up to the user, not the 
`argparse` developers.

Importing path specific modules such as pathlib (which in turn has a lot of 
imports) goes against the attempt to reduce the number of unnecessary imports 
with modules like argparse.

https://bugs.python.org/issue30152
Reduce the number of imports for argparse

After this diet argparse still imports os, and uses:

    os.path.basename

I might also note that argparse has only one custom 'type' function, the 
FileType factory.  Other common type functions like 'int' and 'float' are 
Python builtin's.  Adding a custom 'bool' (to be used instead of the builtin 
'bool') has been rejected.

https://bugs.python.org/issue37564

json, yaml, and datetime types have also been rejected
https://bugs.python.org/issue35005

----------

_______________________________________
Python tracker <rep...@bugs.python.org>
<https://bugs.python.org/issue42572>
_______________________________________
_______________________________________________
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com

Reply via email to