On Thu, Apr 7, 2016 at 2:41 AM, Brett Cannon <br...@python.org> wrote:
> > > On Wed, 6 Apr 2016 at 10:36 Michel Desmoulin <desmoulinmic...@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 <songofaca...@gmail.com>
_______________________________________________ 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