[Python-Dev] Defining a path protocol (original) (raw)
INADA Naoki songofacandy at gmail.com
Thu Apr 7 03:00:49 EDT 2016
- Previous message (by thread): [Python-Dev] Defining a path protocol
- Next message (by thread): [Python-Dev] Defining a path protocol
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]
On Thu, Apr 7, 2016 at 2:41 AM, Brett Cannon <brett at python.org> wrote:
On Wed, 6 Apr 2016 at 10:36 Michel Desmoulin <desmoulinmichel at gmail.com> wrote: Wouldn't be better to generalize that to a "location" protocol, which allow to return any kind of location, including path, url or coordinate, ipaddress, etc ?
No because all of those things have different semantic meaning. See the index PEP for reasons why you would tightly bound protocols instead of overloading ones like int for multiple meanings. -Brett
https://www.python.org/dev/peps/pep-0357/
It is not possible to use the nbint (and int special method) for this purpose because that method is used to coerce objects to integers.
I feel adding protocol only for path is bit over engineering. So I'm -0.5 on adding fspath.
I'm +1 on adding general protocol for coerce to string like index. +0.5 on inherit from str (and drop byte path support).
-- INADA Naoki <songofacandy at gmail.com> -------------- next part -------------- An HTML attachment was scrubbed... URL: <http://mail.python.org/pipermail/python-dev/attachments/20160407/0450c927/attachment.html>
- Previous message (by thread): [Python-Dev] Defining a path protocol
- Next message (by thread): [Python-Dev] Defining a path protocol
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]