Get relative path



    Python public recipes

    The os.path.relpath() function returns the relative path to a file or directory. In this case, it returns the path to the /etc/passwd file.

    Shortcut: file.path.relative

    import os
    os.path.relpath(directory, base_directory)
    Codiga Logo
    Codiga Hub
    • Rulesets
    • Playground
    • Snippets
    • Cookbooks
    • Security
    • Privacy Policy
    • Code Privacy
    • Terms of Service
    soc-2 icon

    We are SOC-2 Compliance Certified

    G2 high performer medal

    Codiga – All rights reserved 2022.