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
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