Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Provide a home() classmethod on Path objects #63976

Closed
pitrou opened this issue Nov 25, 2013 · 8 comments
Closed

Provide a home() classmethod on Path objects #63976

pitrou opened this issue Nov 25, 2013 · 8 comments
Labels
easy stdlib Python modules in the Lib dir type-feature A feature request or enhancement

Comments

@pitrou
Copy link
Member

pitrou commented Nov 25, 2013

BPO 19777
Nosy @pitrou, @vstinner, @vadmium, @serhiy-storchaka
Files
  • path_home.patch
  • path_home2.patch
  • home.patch
  • Note: these values reflect the state of the issue at the time it was migrated and might not reflect the current state.

    Show more details

    GitHub fields:

    assignee = None
    closed_at = <Date 2015-01-13.00:48:28.410>
    created_at = <Date 2013-11-25.20:04:23.333>
    labels = ['easy', 'type-feature', 'library']
    title = 'Provide a home() classmethod on Path objects'
    updated_at = <Date 2015-01-13.00:48:28.408>
    user = 'https://github.com/pitrou'

    bugs.python.org fields:

    activity = <Date 2015-01-13.00:48:28.408>
    actor = 'pitrou'
    assignee = 'none'
    closed = True
    closed_date = <Date 2015-01-13.00:48:28.410>
    closer = 'pitrou'
    components = ['Library (Lib)']
    creation = <Date 2013-11-25.20:04:23.333>
    creator = 'pitrou'
    dependencies = []
    files = ['37581', '37582', '37595']
    hgrepos = []
    issue_num = 19777
    keywords = ['patch', 'easy']
    message_count = 8.0
    messages = ['204388', '204459', '225246', '233403', '233528', '233887', '233888', '233898']
    nosy_count = 9.0
    nosy_names = ['pitrou', 'vstinner', 'Arfrever', 'neologix', 'python-dev', 'martin.panter', 'serhiy.storchaka', 'oquanox', 'artifex93']
    pr_nums = []
    priority = 'low'
    resolution = 'fixed'
    stage = 'resolved'
    status = 'closed'
    superseder = None
    type = 'enhancement'
    url = 'https://bugs.python.org/issue19777'
    versions = ['Python 3.5']

    @pitrou
    Copy link
    Member Author

    pitrou commented Nov 25, 2013

    Similar to Path.cwd(), perhaps a Path.home() to create a new Path object pointing to the current user's home directory may be useful.

    @pitrou pitrou added stdlib Python modules in the Lib dir type-feature A feature request or enhancement labels Nov 25, 2013
    @neologix
    Copy link
    Mannequin

    neologix mannequin commented Nov 26, 2013

    IMO, this functionality is subsumed by http://bugs.python.org/issue19776
    (Path.expanduser).

    @pitrou
    Copy link
    Member Author

    pitrou commented Aug 12, 2014

    IMO, this functionality is subsumed by http://bugs.python.org/issue19776

    Roughly, yes, but it can also be a useful convenience (expanduser('~') isn't that user-friendly, especially for Windows users).

    @pitrou pitrou added the easy label Jan 1, 2015
    @oquanox
    Copy link
    Mannequin

    oquanox mannequin commented Jan 4, 2015

    Added docs to mcsalgado's patch.

    @vstinner
    Copy link
    Member

    vstinner commented Jan 6, 2015

    I agree that Path.home() is more user friendly than Path.expanduser('~').

    @vstinner
    Copy link
    Member

    vstinner commented Jan 12, 2015

    + def _test_home(self, p):
    + q = self.cls(os.path.expanduser('~'))
    + self.assertEqual(p, q)
    + self.assertEqual(str(p), str(q))
    + self.assertIs(type(p), type(q))
    + self.assertTrue(p.is_absolute())
    +
    + def test_home(self):
    + p = self.cls.home()
    + self._test_home(p)

    Why are you using a submethod _test_home()?

    @python-dev
    Copy link
    Mannequin

    python-dev mannequin commented Jan 12, 2015

    New changeset 4a55b98314cd by Antoine Pitrou in branch 'default':
    Issue bpo-19777: Provide a home() classmethod on Path objects.
    https://hg.python.org/cpython/rev/4a55b98314cd

    @pitrou
    Copy link
    Member Author

    pitrou commented Jan 13, 2015

    I've committed the patch, thank you!

    @pitrou pitrou closed this as completed Jan 13, 2015
    @ezio-melotti ezio-melotti transferred this issue from another repository Apr 10, 2022
    Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
    Labels
    easy stdlib Python modules in the Lib dir type-feature A feature request or enhancement
    Projects
    None yet
    Development

    No branches or pull requests

    2 participants