One can easily find out the current working directory by making use of the Python computer programming language, since it comes with all the utilities required to interact with the functionalities of the operating system.
Before going any further with this tutorial, make sure to launch a new Python interactive console on your own operating system.
Once you have managed to launch your Python interactive shell, make use of the following Python statement to import the module which we need to utilize in order to get the current working directory.
What's the one thing every developer wants? More screens! Enhance your coding experience with an external monitor to increase screen real estate.
import os
For those of you who don’t know, the Python computer programming language offers the os module to interact with the functionalities provided by the operating system.
Now, use the os.getcwd utility like shown below to get the current working directory.
os.getcwd()
Once the above piece of Python code gets executed in my Python interactive console, the following output is being displayed.
‘/Users/oltjano/Desktop/Test’
Final thoughts
Depending on the path of the current directory which you are making use of, for sure that you are going to get a different output on your Python interactive console.