[Python-Dev] pathlib handling of trailing slash (Issue #21039)

Alexander Belopolsky alexander.belopolsky at gmail.com
Fri Aug 8 15:39:43 CEST 2014


On Fri, Aug 8, 2014 at 8:27 AM, Paul Moore <p.f.moore at gmail.com> wrote:

> I had a use case where I wanted to allow a config file to contain
> "path: foo" to create a file called foo, and "path: foo/" to create a
> directory. It was a shortcut for specifying an explicit "directory:
> true" parameter as well.
>

Here is my use case: I have a database application that can save a table in
a variety of formats based on the supplied file name.  For example,
save('t.csv', t) saves in CSV text format while save('t', t)  saves in the
default binary format.  In addition, it supports "splayed" format where a
table is saved in multiple files across a directory - one file per column.
 The native database save function chooses this format when file name ends
with a slash: save('t/', t).   I would like to make the save() function in
Python that works like this, but takes pathlib.Path instances instead of
str, but in the current version, I cannot supply 't/' as a Path instance.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.python.org/pipermail/python-dev/attachments/20140808/b4e7bd85/attachment.html>


More information about the Python-Dev mailing list