[Python-Dev] The path module PEP

Charles Cazabon python at discworld.dyndns.org
Tue Jan 24 21:56:51 CET 2006


BJörn Lindqvist <bjourne at gmail.com> wrote:
> 
>     1. Make all python files in the a directory executable:
[...]
>         ==>
>         for f in Path('/usr/home/guido/bin'):
>             f.chmod(0755)

Iterating over a path string to read the contents of the directory possibly
pointed to by that string seems like "magic implicit" behaviour.  Perhaps
making it a method explicitly returning an iterator would by more Pythonic?

    for f in Path(...).readDir():

>     4. Splitting a path into directory and filename:
[...]
>         Path("/path/to/foo/bar.txt").splitpath()

Good.  But the opposite isn't done similarly:

>     6. Create directory paths:
[...]
>         Path("foo") / "bar" / "baz"

Using "/" as "path concatenation operator" seems like un-Pythonic magic as
well (while "+" would be an improvement, it's still not a large one).  I would
think 

    Path('foo').appendparts('bar', 'baz')

or similar would be more readable and obvious.

Charles
-- 
-----------------------------------------------------------------------
Charles Cazabon                           <python at discworld.dyndns.org>
GPL'ed software available at:               http://pyropus.ca/software/
-----------------------------------------------------------------------


More information about the Python-Dev mailing list