A RetroSearch Logo

Home - News ( United States | United Kingdom | Italy | Germany ) - Football scores

Search Query:

Showing content from https://mail.python.org/pipermail/python-dev/2016-May/144522.html below:

[Python-Dev] file system path protocol PEP

[Python-Dev] file system path protocol PEPEthan Furman ethan at stoneleaf.us
Wed May 11 17:52:54 EDT 2016
On 05/11/2016 02:28 PM, Nikolaus Rath wrote:
> On May 11 2016, Brett Cannon wrote:

>> This PEP proposes a protocol for classes which represent a file system
>> path to be able to provide a ``str`` or ``bytes`` representation.
> [...]
>
> As I said before, to me this seems like a lot of effort for a very
> specific use-case. So let me put forward two hypothetical scenarios to
> better understand your position:
>
> - A new module for URL handling is added to the standard library (or
>    urllib is suitably extended). There is a proposal to add a new
>    protocol that allows classes to provide a ``str`` or ``bytes``
>    representation of URLs.
>
> - A new (third-party) library for natural language processing arises
>    that exposes a specific class for representing audio data. Existing
>    language processing code just uses bytes objects. To ease transition
>    and interoperability, it is proposed to add a new protocol for classes
>    that represend audio data to provide a bytes representation.
>
> Do you think you would you be in favor of adding these protocols to
> the stdlib/languange reference as well? If not, what's the crucial
> difference to file system paths?

I think a crucial reason for this work is to unify the stdlib: we 
currently have four (?) different things that can be or represent a 
file-system path:

- str
- bytes
- DirEntry
- Path

Half of those objects don't work well with the rest of the standard library.

As for your second example, the protocol already exists: it's called 
__bytes__.  ;)

--
~Ethan~
More information about the Python-Dev mailing list

RetroSearch is an open source project built by @garambo | Open a GitHub Issue

Search and Browse the WWW like it's 1997 | Search results from DuckDuckGo

HTML: 3.2 | Encoding: UTF-8 | Version: 0.7.4