[Python-ideas] PEP 428 - object-oriented filesystem paths
Antoine Pitrou
solipsis at pitrou.net
Fri Oct 12 22:53:06 CEST 2012
On Fri, 12 Oct 2012 13:33:14 -0700
Ethan Furman <ethan at stoneleaf.us> wrote:
> Antoine Pitrou wrote:
> > On Fri, 12 Oct 2012 12:23:46 -0700
> > Ethan Furman <ethan at stoneleaf.us> wrote:
> >> Which is why I would like to see Path based on str, despite Guido's
> >> misgivings. (Yes, I know I'm probably tilting at windmills here...)
> >>
> >> If Path is string based we get backwards compatibility with all the os
> >> and third-party tools that expect and use strings; this would allow a
> >> gentle migration to using them, as opposed to the all-or-nothing if Path
> >> is a completely new type.
> >
> > It is not all-or-nothing since you can just call str() and it will work
> > fine with both strings and paths.
>
> D'oh. You're correct, of course.
>
> What I was thinking was along the lines of:
>
> --> some_table = Path('~/addresses.dbf')
> --> some_table = os.path.expanduser(some_table)
>
> vs
>
>
> --> some_table = Path('~/addresses.dbf')
> --> some_table = Path(os.path.expanduser(str(some_table)))
Hey, nice catch, I need to add a expanduser()-alike to the Path API.
Thank you!
Antoine.
--
Software development and contracting: http://pro.pitrou.net
More information about the Python-ideas
mailing list