You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
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:
frompathlibimportPathdata_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
importosdata_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/'
The text was updated successfully, but these errors were encountered:
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:
and/or also use
os.path.join
The text was updated successfully, but these errors were encountered: