Paths

I run the command

pip install pathlib

to get the library I need.

Then I copy Exercises_11 to my project and call it Network.

Once my project becomes more complex, I may need to be more sophisticated in how I handle paths.

In the root directory, I create a file called mypaths.py and I define how to find some of my important files.

I edit main.py

And I get the result

We do all the hard work in mypaths.py and keep our code nice and readable in main.py

Read about pathlibarrow-up-right, it is very powerful once we have complex directory structures.

Last updated