python / python/cpython

Expose file size, mode, etc from `pathlib.Path.info`

Open
#139,174 0 comments 3 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

stdlib topic-pathlib type-feature
Dominant language
Python
Stars
77.2k
Forks
35.9k
PR merge metrics
PR metrics pending

Description

Feature or enhancement

Proposal:

As a pathlib user, I desire methods that retrieve the file mode, size, access time and modify time.

We can implement these as methods of Path.info.

    def mode(self, *, follow_symlinks: bool = True) -> int: ...
    def size(self, *, follow_symlinks: bool = True) -> int: ...
    def access_time(self, *, follow_symlinks: bool = True) -> datetime: ...
    def modify_time(self, *, follow_symlinks: bool = True) -> datetime: ...
Has this already been discussed elsewhere?

I have already discussed this feature proposal on Discourse

Links to previous discussion of this feature:

https://discuss.python.org/t/expose-file-size-mode-etc-from-pathlib-path-info/103828

Linked PRs
  • gh-139175
  • gh-139183
  • gh-139279
  • gh-140155

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start with the Path.info documentation and the linked Discourse discussion to understand the proposed API. Review linked PRs gh-139175, gh-139183, gh-139279, and gh-140155 before making changes; the work is done when the proposal has an agreed implementation and the requested Path.info methods are supported.

Written by the indexing model from the issue text.

Assessment

Tech stack
python
Domain
operating-systems
Issue type
Feature
Difficulty
5/5
Estimated time
Over a week
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
20/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.