A RetroSearch Logo

Home - News ( United States | United Kingdom | Italy | Germany ) - Football scores

Search Query:

Showing content from http://mail.python.org/pipermail/python-dev/attachments/20160512/62f6c160/attachment.html below:

<div dir="ltr"><div class="gmail_extra"><div class="gmail_quote">On Thu, May 12, 2016 at 10:18 AM, Brett Cannon <span dir="ltr"><<a href="mailto:brett@python.org" target="_blank">brett@python.org</a>></span> wrote:<br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><div dir="ltr"><br><div class="gmail_quote"><span class=""><div dir="ltr">On Thu, 12 May 2016 at 09:25 Guido van Rossum <<a href="mailto:guido@python.org" target="_blank">guido@python.org</a>> wrote:</div></span><span class=""></span><span class=""><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><div dir="ltr"><div>def fspath(p: Union[str, bytes, PathLike]) -> Union[str, bytes]:<br></div><div>    if isinstance(p, (str, bytes)):<br></div><div>        return p<br></div><div>    try:<br></div><div>        return p.__fspath__<br></div><div>    except AttributeError:<br></div><div>        raise TypeError(...)<span style="line-height:1.5"> </span></div></div></blockquote><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><div dir="ltr"><div><br></div>Other than that I think the PEP is already in fine shape.</div></blockquote><div><br></div></span>- Bytes: I strongly believe that os.fspath() should be a thin wrapper around the __fspath__ protocol, like next() wraps the .__next__ protocol. It should not get into bytes vs. string politics. If your app really needs strings, call os.fsdecode(). So this is my version (unoptimized):<br><br><div>Just to double-check, did you mean for __fspath__ to only be an attribute in your example, or did you leave off the `()` by accident? As of right now the PEP is proposing a method for the protocol to follow common practice of using methods and in case the representation is not always pre-computed and thus not necessarily giving the wrong impression that the attribute access is cheap. But admittedly an attribute was previously proposed and there wasn't a terribly strong argument against it beyond "we historically haven't done it that way", so I'm open to swapping to an attribute if that's your preference.</div><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><div dir="ltr"><div><div><div><div><div><div class="gmail_extra">
</div></div></div></div></div></div></div></blockquote></div></div>
</blockquote></div><br></div><div class="gmail_extra">Whoops. Didn't mean to change that! Yes, __fspath__ should remain a method. You can breathe again. :-)<br clear="all"></div><div class="gmail_extra"><br>-- <br><div class="gmail_signature">--Guido van Rossum (<a href="http://python.org/~guido" target="_blank">python.org/~guido</a>)</div>
</div></div>

RetroSearch is an open source project built by @garambo | Open a GitHub Issue

Search and Browse the WWW like it's 1997 | Search results from DuckDuckGo

HTML: 3.2 | Encoding: UTF-8 | Version: 0.7.4