[Python-ideas] Dunder method to make object str-like

Chris Angelico rosuav at gmail.com
Thu Apr 7 12:44:17 EDT 2016

On Fri, Apr 8, 2016 at 2:11 AM, Paul Moore <p.f.moore at gmail.com> wrote:
> Even worse, what should open() do? It takes a string as an argument.
> To support patthlib, it needs to also call __fspath__. I presume you'd
> also want it to call __fromstring__ so that your Ascii class could be
> used as an argument to open as well. This is starting to seem
> incredibly messy to solve a problem that's basically about extending
> support for Python 2, which is explicitly not something the Python 3
> core should be doing...

This would replace __fspath__. There'd be no need for a Path-specific
dunder if there's a generic "this can be treated as a string" dunder.


More information about the Python-ideas mailing list