[go: up one dir, main page]

Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Handle paths using Pathlib and/or os.path.join #18

Open
luisaforozco opened this issue Dec 8, 2022 · 3 comments
Open

Handle paths using Pathlib and/or os.path.join #18

luisaforozco opened this issue Dec 8, 2022 · 3 comments
Assignees
Labels
enhancement New feature or request

Comments

@luisaforozco
Copy link
Collaborator

Since GL is a package that is going to be used by users in different platforms i.e. windows, linux, macOS, it is necessary that the paths will be platform independent. Currently GL works in macOS and linux but it wouldn't in windows, where the paths are with single or double \ instead of /.

To solve this I propose:

use pathlib:

from pathlib import Path
data_folder = Path("source_data/text_files/")
file_to_open = data_folder / "raw_data.txt"

# It also works concatenating multiple strings on the fly:
>>> a_string = "path/to/something"
>>> a_path = Path(a_string+"/new/directory/type")
PosixPath('path/to/something/new/directory/type')

# and adding a str to a Path
>>> a_path / "new/string/path"
PosixPath('path/to/something/new/directory/type/new/string/path')

and/or also use os.path.join

import os
data_folder = os.path.join("source_data", "text_files")
file_to_open = os.path.join(data_folder, "raw_data.txt")

# This also works concatenating a string and a pathlib Path
>>> ab = Path("test/one")
>>> os.path.join(ab,"other/test/")
'test/one/other/test/'
@luisaforozco luisaforozco added the enhancement New feature or request label Dec 8, 2022
@luisaforozco luisaforozco self-assigned this Dec 8, 2022
@chyalexcheng
Copy link
Contributor

GL works on windows with anaconda and visual studio. We tested this during the TUSAIL school

@luisaforozco
Copy link
Collaborator Author

Ok, so are you sure this is not needed?

@luisaforozco
Copy link
Collaborator Author

@chyalexcheng I see that in commit c7a86a8 you are amending some paths. Check if what I posted here is useful.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

No branches or pull requests

2 participants