[Python-ideas] PEP 428: poll about the joining syntax

Antoine Pitrou solipsis at pitrou.net
Tue Oct 9 14:34:36 CEST 2012

Nick Coghlan <ncoghlan at ...> writes:
> One note regarding the extra "str()" calls relative to something like
> path.py: we get to define the language, so we can get the benefits of
> implicit conversion without the many downsides by *defining a new
> conversion method*, such as __fspath__. That may provide an attractive
> alternative to offering methods that shadow builtin functions:
>     open(Path(home, ".config", name + ".conf"))
>     open(home.join(".config", name + ".conf"))
>     open(home / ".config" / name + ".conf")
> "As easy to use as path.py, without the design compromises imposed by
> inheriting from str" is a worthwhile goal.

That's a very good idea! Even better if there's a way to make it work as
expected with openat support (for example by allowing __fspath__ to return
a (dir_fd, filename) tuple).



More information about the Python-ideas mailing list