Re: [Python-Dev] pathlib (was: Defining a path protocol)

2016-04-10 Thread Greg Ewing

Nick Coghlan wrote:

We want to be able to readily use the protocol helper in builtin
modules like os and low level Python modules like os.path, which means
we want it to be much lower down in the import hierarchy than pathlib.


Also, it's more general than that. It works on any
object that wants to behave as a path, not just
pathlib ones, so it should be in a neutral place.

--
Greg
___
Python-Dev mailing list
Python-Dev@python.org
https://mail.python.org/mailman/listinfo/python-dev
Unsubscribe: 
https://mail.python.org/mailman/options/python-dev/archive%40mail-archive.com


Re: [Python-Dev] pathlib (was: Defining a path protocol)

2016-04-09 Thread Nick Coghlan
On 8 April 2016 at 00:25, Jim J. Jewett  wrote:
> (1)  I think the "built-in" should instead be a module-level function
> in the pathlib.  If you aren't already expecting pathlib paths, then
> you're just expecting strings to work anyhow, and a builtin isn't
> likely to be helpful.

Concrete data in relation to "Why not put the helper function in pathlib?":

>>> import sys
>>> orig_modules = set(sys.modules)
>>> "os" in orig_modules
True
>>> import pathlib
>>> extra_dependencies = set(sys.modules) - orig_modules
>>> print(sorted(extra_dependencies))
['_collections', '_functools', '_heapq', '_operator', '_sre',
'collections', 'contextlib', 'copyreg', 'fnmatch', 'functools',
'heapq', 'itertools', 'keyword', 'ntpath', 'operator', 'pathlib',
're', 'reprlib', 'sre_compile', 'sre_constants', 'sre_parse',
'urllib', 'urllib.parse', 'weakref']

We want to be able to readily use the protocol helper in builtin
modules like os and low level Python modules like os.path, which means
we want it to be much lower down in the import hierarchy than pathlib.

Cheers,
Nick.

-- 
Nick Coghlan   |   ncogh...@gmail.com   |   Brisbane, Australia
___
Python-Dev mailing list
Python-Dev@python.org
https://mail.python.org/mailman/listinfo/python-dev
Unsubscribe: 
https://mail.python.org/mailman/options/python-dev/archive%40mail-archive.com


[Python-Dev] pathlib (was: Defining a path protocol)

2016-04-07 Thread Jim J. Jewett
(1)  I think the "built-in" should instead be a module-level function
in the pathlib.  If you aren't already expecting pathlib paths, then
you're just expecting strings to work anyhow, and a builtin isn't
likely to be helpful.

(2)  I prefer that the function be explicit about the fact that it is
downcasting the representation to a string.  e.g.,
pathlib.path_as_string(my_path)

But if the final result is ospath or fspath or ... I won't fight too
hard, particularly since the output may be a bytestring rather than a
str.

-jJ
___
Python-Dev mailing list
Python-Dev@python.org
https://mail.python.org/mailman/listinfo/python-dev
Unsubscribe: 
https://mail.python.org/mailman/options/python-dev/archive%40mail-archive.com