[Tutor] File path requirements (absolute or relative)?

Alan Gauld alan.gauld at yahoo.co.uk
Fri May 15 17:46:41 EDT 2020


On 15/05/2020 21:31, boB Stepp wrote:
> My file structure for a project is as follows:
> 
> ~
>      | Projects
>          | project_name
>              | docs
>              | src
>                  project_name.py
>              | tests
>                  test.py
>                  test_csv_file.csv
> 
> I wish to pass the path for "test_csv_file.csv" from the test.py program to
> the function in src/project_name.py which processes csv files.  Ideally I
> would like to use a relative path name like "../tests/test_csv_file" and
> have the function in src/project_name.py to be able to use it.  But so far
> all of my efforts to use a relative path name have failed. 

Can you show us some code?

Relative paths should work, but they will b relative to the CWD.
Where are you running the code from?


-- 
Alan G
Author of the Learn to Program web site
http://www.alan-g.me.uk/
http://www.amazon.com/author/alan_gauld
Follow my photo-blog on Flickr at:
http://www.flickr.com/photos/alangauldphotos




More information about the Tutor mailing list