Skip to content

stat: provide reverse operation of stat.filemode() #108185

@calestyo

Description

@calestyo

Feature or enhancement

Has this already been discussed elsewhere?

This is a minor feature, which does not need previous discussion elsewhere

Links to previous discussion of this feature:

No response

Proposal:

Hey.

stat.filemode() (which is IMO rather unfortunately named, as it doesn't return the actual file mode (bits) but just one of the string notations for it is quite helpful for many cases.

But I think the reverse function, that is converting a file mode in some string notation to the actual (binary) file mode, would also be nice to have as a convenience function.

Subsequently I'll provide a draft PR, that gives a poor man's example of how this could be done, re-using the existing stat._filemode_table.

The draft is based on what I use personally for this,… it would need to be further improved of course (see the PR, for what's missing).

But this should serve as a start so that Python core devs could decided whether they'd even want such a function at all in Pyhton.

Any opinions? :-)

Cheers,
Chris.

Linked PRs

Metadata

Metadata

Assignees

No one assigned

    Labels

    stdlibStandard Library Python modules in the Lib/ directorytype-featureA feature request or enhancement

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions