[Python-Dev] PEP 428 - pathlib - ready for approval

Chris Barker chris.barker at noaa.gov
Wed Nov 20 23:43:26 CET 2013


On Wed, Nov 20, 2013 at 1:39 PM, Giampaolo Rodola' <g.rodola at gmail.com>wrote:

> Isn't this redundant?
>
> >>> Path.cwd()
> PosixPath('/home/antoine/pathlib')
>
> Probably this is just personal taste but I'd prefer the more explicit:
>
> >>> Path(os.getcwd())
> PosixPath('/home/antoine/pathlib')
>
> I understand all the os.* replication (Path.rename, Path.stat etc.) but
> all these methods assume you're dealing with an instantiated Path instance
> whereas Path.cwd is the only one which doesn't.
>

That's a standard pattern for using a classmethod as an alternate
constructor -- similar to:

datetime.now()
dict.fromkeys()
etc....

and it can really reduce namespace clutter (do you really want to import
both os and path for this? (OK, you way well be importing os anyway, but...)

It also allows you to get that functionality in a subclass.

Anyway, it's not that different, and I like it ;-)

Other than that the module looks absolutely awesome and a big improvement
> over os.path!
>

indeed -- thanks for moving this forward, it is a long time coming!

By the way, for us dinosaurs  is this going to exactly match the
pathlib implementation that can be used with py2?

-Chris

>

-- 

Christopher Barker, Ph.D.
Oceanographer

Emergency Response Division
NOAA/NOS/OR&R            (206) 526-6959   voice
7600 Sand Point Way NE   (206) 526-6329   fax
Seattle, WA  98115       (206) 526-6317   main reception

Chris.Barker at noaa.gov
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.python.org/pipermail/python-dev/attachments/20131120/b1e5b7ab/attachment-0001.html>


More information about the Python-Dev mailing list