How to simply handle errors when importing modules in Python

Based on my personal experience with the Python computer programming language, the builtin import statement is being used to make use of different modules part of the Python technology.

For example, when a Python coder needs the functionalities included in the os builtin module, they have to import it by making use of the code which is shown below. Continue reading “How to simply handle errors when importing modules in Python”

How to find the email address from a Python string by using a custom regular expression

Regular expressions are very useful to the Python coder, especially if they have to deal with a lot of output in the form of text. Through this tutorial, you will learn how to find an email address from a Python long string object by making use of the regular expressions. Continue reading “How to find the email address from a Python string by using a custom regular expression”

How to find a pattern with re.search in a Python string

Regular expressions are very useful to the Python geek, especially when they have to deal with a lot of data which comes in the form of text. Being very rich in features, the Python computer programming language comes with a builtin module which offers the functionalities and utilities to construct regular expressions based on the coder’s needs. Continue reading “How to find a pattern with re.search in a Python string”

How to pass **kwargs inside a Python function

In one of the previous tutorials about the Python computer programming language, we learned how to make use of the *args syntax to pass arguments inside a function. Through this article, you are going to learn how to make use of the **kwargs Python syntax to automatically pass keyword based arguments inside a function.
Continue reading “How to pass **kwargs inside a Python function”

How to override a method in a Python class

The class utility offered by the Python computer programming language, is a very important tool to the Python coder as it offers a way to develop custom extension classes which inherit attributes from a base one. By using the class utility offered by the Python computer programming language, the developer can easily get the most out of the object oriented programming concept. Continue reading “How to override a method in a Python class”

How to find your Python version the geek way

As a computer geek, I like to experiment with different command line utilities with the main purpose of finding new ways to automate daily tasks in my own operating system. Python is one of my favorite computer tool so far, as not only it helps me to write my custom utilities, but is also easy to read and understand.

Through this article, you are going to learn how you can find the version of Python which is installed in your own machine. There are many ways to accomplish such task, but for the purpose of this tutorial I am going to share the two I know. Continue reading “How to find your Python version the geek way”

How to execute commands of the unix based operating system in Python

Every operating system I am aware of comes with a command line utility through which the wise computer geek can execute commands and interact with the functionalities provided by it. Based on my personal experience with computers so far, Unix based machines offer a terminal utility to help the user run specific builtin commands which interact with the goodies offered by the operating system. On the other hand, Windows based machines come with what is known as CMD, similar to the terminal tool offered in Unix based operating systems.

Both the Unix terminal and the Windows CMD utilities, are being built to help the computer nerd get the most out of their own operating system. Before one can fully make use of these utilities, they should learn about the scripting language supported by them. Continue reading “How to execute commands of the unix based operating system in Python”