A RetroSearch Logo

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

Search Query:

Showing content from https://mail.python.org/pipermail/python-dev/2016-April/143757.html below:

[Python-Dev] Defining a path protocol

[Python-Dev] Defining a path protocol [Python-Dev] Defining a path protocolPaul Moore p.f.moore at gmail.com
Thu Apr 7 07:05:43 EDT 2016
On 7 April 2016 at 11:48, Nikolaus Rath <Nikolaus at rath.org> wrote:
> Why is:
>
> path = getattr(obj, '__fspath__') if hasattr(obj, '__fspath__') else obj
>
> better than
>
> path = str(obj) if isinstance(obj, pathlib.Path) else obj

One reason is that the former doesn't need you to import pathlib,
which is good if you need to work with older versions of Python that
don't have pathlib at all (yes, it's just some standard conditional
import boilerplate, but it's additional messiness).

Paul
More information about the Python-Dev mailing list

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