[Python-ideas] Updated PEP 428 (pathlib)

Antoine Pitrou solipsis at pitrou.net
Sun Mar 3 11:41:12 CET 2013


On Sun, 3 Mar 2013 09:46:16 +0100
Charles-François Natali
<cf.natali at gmail.com> wrote:
> 
> >>> p = PureNTPath('c:/Downloads/pathlib.tar.gz')
> >>> p.name
> 'pathlib.tar.gz'
> >>> p.basename
> 'pathlib.tar'
> >>> p.suffix
> '.gz'
> 
> I find the 'p.basename' name confusing: following POSIX conventions,
> 'basename' should be 'pathlib.tar.gz'. I don't have another 'name' to
> propose for the stripped name, though.

Yes. We could call it
"root" (http://en.wikipedia.org/wiki/Root_%28linguistics%29) but in
this context it would be confusing. Also, it's not exactly the root
since as you point there can still be a remaining suffix.

There's "stem", too (http://en.wikipedia.org/wiki/Word_stem). With the
same provision about not being the actual stem.

> > match() matches the path against a glob pattern:
> 
> I think it could be interesting to add an optional argument to
> mitigate glob-based DoS. Whether this should be made default is left
> as an exercise to the reader :-)

You mean for glob() (match() is just a regex-like matcher, it doesn't
do any I/O).  Yes, I think we could add a `allow_recursive` argument.
Is there any other DoS issue?

Regards

Antoie.





More information about the Python-ideas mailing list