<div dir="ltr"><br><br><div class="gmail_quote"><div dir="ltr">On Wed, 15 Jun 2016 at 12:12 Koos Zevenhoven <<a href="mailto:k7hoven@gmail.com">k7hoven@gmail.com</a>> wrote:<br></div><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">>>     if isinstance(filename, os.PathLike):<br>
<br>
By the way, regarding the line of code above, is there a convention<br>
regarding whether implementing some protocol/interface requires<br>
registering with (or inheriting from) the appropriate ABC for it to<br>
work in all situations. IOW, in this case, is it sufficient to<br>
implement __fspath__ to make your type pathlike? Is there a conscious<br>
trend towards requiring the ABC?<br></blockquote><div><br></div><div>ABCs like os.PathLike can override __subclasshook__ so that registration isn't required (see <a href="https://hg.python.org/cpython/file/default/Lib/os.py#l1136">https://hg.python.org/cpython/file/default/Lib/os.py#l1136</a>). So registration is definitely good to do to be explicit that you're trying to meet an ABC, but it isn't strictly required. <br></div></div></div>