Operating System

Creating, Reading & Updating A Config File with Python

Subtitle: Avoid Hard-Coded Data While Making Your (And Others) Life Easier When the subject of config, or configuration, files comes up there is often confusion on what they are, how to read them, and the benefits that come from their use. In this article, we will cover what config files are before introducing the Python …

Creating, Reading & Updating A Config File with Python Read More »

What’s the Best Way to Save Image Metadata Alongside a TIFF?

Problem Formulation You create images in the Tag Image File Format (TIFF). You want to add custom metadata to the image such as the location or other context information important for post-processing. How can you accomplish this? Solution Install and import the library tiffile. Use the tiffile.imsave() function to store the file at a given …

What’s the Best Way to Save Image Metadata Alongside a TIFF? Read More »

How To Run Multiple Python Versions On Windows?

Summary: You can run multiple versions of Python on Windows using one of the following methods: Using entire path to execute the code. Creating A Shortcut or Symbolic Link to the executable files. Using Pylauncher: Use Shebang (#) in The Script Run Pylauncher Command Using Virtual Environments. ➠ Problem Formulation: You might have two versions …

How To Run Multiple Python Versions On Windows? Read More »

Python open() Function — An 80/20 Guide By Example

Python’s built-in open() function opens a file and returns a file object. The only non-optional argument is a filename as a string of the file to be opened. You can use the file object to access the file content. For example, file_obj.readlines() reads all lines of such a file object. Here’s a minimal example of …

Python open() Function — An 80/20 Guide By Example Read More »

How to Access Environment Variable Values in Python?

Problem Formulation: Say, you set an environment variable and you want to access it in your Python script. How to get the value of the environment variable? Background: Environment variables are external to the Python environment.  They describe the operating system environment we are using. The applications installed use this information to complete specific tasks …

How to Access Environment Variable Values in Python? Read More »