Rietveld Code Review Tool
Help | Bug tracker | Discussion group | Source code | Sign in
(58205)

#19777: Provide a home() classmethod on Path objects

Can't Edit
Can't Publish+Mail
Start Review
Created:
4 years, 5 months ago by pitrou
Modified:
4 years, 5 months ago
Reviewers:
victor.mcsalgado
CC:
AntoinePitrou, haypo, Arfrever, Charles-Fran├žois Natali, devnull_psf.upfronthosting.co.za, Martin Panter, storchaka, oquanox, artifex93
Visibility:
Public.

Patch Set 1 #

Total comments: 2

Patch Set 2 #

Total comments: 2

Patch Set 3 #

Unified diffs Side-by-side diffs Delta from patch set Stats Patch
Doc/library/pathlib.rst View 1 2 1 chunk +11 lines, -0 lines 0 comments Download
Lib/pathlib.py View 1 2 1 chunk +7 lines, -0 lines 0 comments Download
Lib/test/test_pathlib.py View 1 2 1 chunk +11 lines, -0 lines 0 comments Download

Messages

Total messages: 4
AntoinePitrou
http://bugs.python.org/review/19777/diff/13512/Lib/pathlib.py File Lib/pathlib.py (right): http://bugs.python.org/review/19777/diff/13512/Lib/pathlib.py#newcode1016 Lib/pathlib.py:1016: return cls(os.path.expanduser('~')) It would be simpler to use the ...
4 years, 5 months ago #1
mcsalgado
http://bugs.python.org/review/19777/diff/13512/Lib/pathlib.py File Lib/pathlib.py (right): http://bugs.python.org/review/19777/diff/13512/Lib/pathlib.py#newcode1016 Lib/pathlib.py:1016: return cls(os.path.expanduser('~')) I submitted another patch, I wouldn't call ...
4 years, 5 months ago #2
AntoinePitrou
Thanks for the updated patch. One more comment; also, you'll have to update the documentation ...
4 years, 5 months ago #3
mcsalgado
4 years, 5 months ago #4
http://bugs.python.org/review/19777/diff/13513/Lib/pathlib.py
File Lib/pathlib.py (right):

http://bugs.python.org/review/19777/diff/13513/Lib/pathlib.py#newcode1015
Lib/pathlib.py:1015: return cls(cls()._flavour.gethomedir(None))
On 2015/01/01 23:57:09, AntoinePitrou wrote:
> `_flavour` is a class attribute, so you shouldn't have to create an
intermediate
> instance here.

So here's what I got after studying the code, please correct me if I got
something wrong:

_flavour is a class attribute in WindowsPath and PosixPath but not in Path or
PurePath. PurePath's __new__ does the work of selecting WindowsPath or PosixPath
so that's why every instance of PurePath has _flavour.

It was a bit confusing to me because there's cls._flavour inside class
methods... But it's actually called from instances every time (in other words,
it's called with cls being an instance).
Sign in to reply to this message.

RSS Feeds Recent Issues | This issue
This is Rietveld 894c83f36cb7+