[Python-Dev] Defining a path protocol (original) (raw)
Paul Moore p.f.moore at gmail.com
Thu Apr 7 07:05:43 EDT 2016
- Previous message (by thread): [Python-Dev] Defining a path protocol
- Next message (by thread): [Python-Dev] Defining a path protocol
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]
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
- Previous message (by thread): [Python-Dev] Defining a path protocol
- Next message (by thread): [Python-Dev] Defining a path protocol
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]