[Python-Dev] proposed os.fspath() change (original) (raw)
Brett Cannon brett at python.org
Wed Jun 15 15:15:01 EDT 2016
- Previous message (by thread): [Python-Dev] proposed os.fspath() change
- Next message (by thread): [Python-Dev] proposed os.fspath() change
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]
On Wed, 15 Jun 2016 at 12:12 Koos Zevenhoven <k7hoven at gmail.com> wrote:
>> if isinstance(filename, os.PathLike):
By the way, regarding the line of code above, is there a convention regarding whether implementing some protocol/interface requires registering with (or inheriting from) the appropriate ABC for it to work in all situations. IOW, in this case, is it sufficient to implement fspath to make your type pathlike? Is there a conscious trend towards requiring the ABC?
ABCs like os.PathLike can override subclasshook so that registration isn't required (see https://hg.python.org/cpython/file/default/Lib/os.py#l1136). So registration is definitely good to do to be explicit that you're trying to meet an ABC, but it isn't strictly required. -------------- next part -------------- An HTML attachment was scrubbed... URL: <http://mail.python.org/pipermail/python-dev/attachments/20160615/104133b0/attachment.html>
- Previous message (by thread): [Python-Dev] proposed os.fspath() change
- Next message (by thread): [Python-Dev] proposed os.fspath() change
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]