Skip to content

Add a "Patterns" chapter #465

Closed
Closed
@matrixise

Description

@matrixise

Yesterday, I have fixed an issue in bpo and this issue was for the support of os.PathLike in FileCookieJar. Since the introduction of os.PathLike and __fspath__, we continue to convert some parts of code to be os.PathLike compliant and I think there is a pattern for that.

Maybe we could create a page "Patterns" with some examples.

For example (but need to be tested and approved)

How to support a os.PathLike object?

def __init__(self, filename):
    try:
        filename = os.fspath(filename)
    except TypeError:
        raise ValueError("filename must be a string-like or path-like object")

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions