[Python-Dev] Defining a path protocol
INADA Naoki
songofacandy at gmail.com
Thu Apr 7 03:00:49 EDT 2016
More information about the Python-Dev mailing list
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, ip_address, 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 nb_int (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 ]
More information about the Python-Dev mailing list