Articles about Python

Python Logo

Python is one of the most versatile programming languages in the world. With Python, you can control electronics, build web applications and perform machine learning.

In this page, you can find articles on Python references, coding and application setup.

How to traverse all folders and files within a folder dynamically in Python 3

I had this requirement where I need to be able to look into a folder and pick up any configuration files for my Python 3 application. In order to achieve that, I first set an exploratory task to get the Python 3 code for traversing all folders and files within a folder.

For this exploratory task, I had created a script that will traverse the folders and files that are contained within a folder and print out their full paths.


How to get the directory path of a Python 3 script from within itself

One of the best way to reference files in Python scripts is to based the file path on the directory where the Python script resides in. This will allow us to always reference our files correctly no matter where our Python script is being executed.

This post documents the Python 3 code that I often used to get the directory path of a Python 3 script from within itself.