Skip to content

Replace many instances of os.path.join() with the corresponding Pathlib.path / syntax #1627

@jlnav

Description

@jlnav

Python's os module can combine filepaths with os.path.join(), e.g.

import os

home = "/user/home"

project_directory = "my_project/directory"

complete_path = os.path.join(home, project_directory)

This is fine, but a Path from pathlib.Path can be combined with another simply with /:

from pathlib import Path

home = Path("/user/home")

project_directory = Path("my_project/directory")

complete_path = home / project_directory

This has other benefits; Path objects can, of course, are filepath objects instead of strings.

We'd appreciate help replacing most instances of os.path.join on strings with the corresponding pathlib syntax on Paths.

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions