Heads up! To view this whole video, sign in with your Courses account or enroll in your free 7-day trial. Sign In Enroll
Well done!
You have completed Python for File Systems!
You have completed Python for File Systems!
Preview
Learn how to change directories from our Python scripts and we'll start looking at the `os` module.
Python Documentation
Related Discussions
Have questions about this video? Start a discussion with the community and Treehouse staff.
Sign upRelated Discussions
Have questions about this video? Start a discussion with the community and Treehouse staff.
Sign up
I know there've been been languages and
systems in the past though,
0:00
where our script would've been executed
in the directory where the Python
0:01
executable lived.
0:04
That would be really annoying.
We would constantly have to change
0:05
the directory that our
script was working in.
0:07
Almost every bit of code that we use in
this course will be using the OS library.
0:10
It's build into Python.
0:15
If you find yourself unable to run a file
or follow along with a bit of code,
0:15
make sure you've imported
the library by using import os.
0:20
Now we can see what directory we're in,
also know as the current working directory
0:24
by using the getcwd function,
os.getcwd or current working directory.
0:29
You need to sign up for Treehouse in order to download course files.
Sign upYou need to sign up for Treehouse in order to set up Workspace
Sign up