On 04/18/2016 12:41 AM, Nick Coghlan wrote: > Given the variant you [Koos] suggested, what if we defined the API semantics > like this: > > # Offer the simplest possible API as the public vesion > def fspath(pathlike) -> str: > return os._raw_fspath(pathlike) > > # Expose the complexity in the "private" variant > def _raw_fspath(pathlike, *, output_types = (str,)) -> (str, bytes): > # Short-circuit for instances of the output type > if isinstance(pathlike, output_types): > return pathlike > # We'd have a tidier error message here for non-path objects > result = pathlike.__fspath__() > if not isinstance(result, output_types): > raise TypeError("argument is not and does not provide an > acceptable pathname") > return result My initial reaction was that this was overly complex, but after thinking about it a couple days I /really/ like it. It has a reasonable default for the 99% real-world use-case, while still allowing for custom and exact tailoring (for the 99% stdlib use-case ;) . -- ~Ethan~
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