Category: python

How To Use Regex In Python (Video)

Continue reading

Log File Parsing In Python (Video)

Log File Parsing In Python Video (Part 1)

Log File Parsing In Python (Part 1)

Log File Parsing In Python Video (Part 2)

Log File Parsing In Python (Part 2)
Continue reading

Can A Python Developer Work From Home?

The COVID-19 pandemic has drastically changed how people work, with remote work becoming more common. Python is a popular programming language used in various industries and you might wonder if you can work from home as a Python developer.

In this article, we will explore the answer to this question and I’ll provide tips for you based on my experience – how I went from working as a QA engineer in the office to becoming an entirely remotely working Python developer.

Can A Python Developer Work From Home?

The short answer is YES, a Python developer can work from home. Many companies allow remote work for their developers, and there are also freelance opportunities for those who prefer to work independently.

In fact, remote work can be particularly well-suited for Python developers, who often work on projects that can be completed independently.

However, it is important to note that some employers may require their developers to work on-site, particularly for certain projects that require close collaboration with other team members.

It is important to clarify your employer’s remote work policy before making any assumptions about working from home.

Continue reading

Can I Build A Log Parsing Tool In Python?

Logs are a critical component of any application or system. They contain valuable information that can help developers troubleshoot issues and improve performance. However, analyzing logs manually can be daunting, especially if there are large volumes of logs to sift through.

Back in the day, when I was still a QA engineer (how I became a Python developer here), I was in this situation a lot and needed to figure out a way to AUTOMATE the parsing/analyzing process.

That’s a perfect opportunity to build your own log parsing tool in Python! 🔥

Recently I happened to run into a similar situation where it made sense to write my own log parsing tool in Python.

In this article, we’ll explore how you can build a log parsing tool in Python and the benefits of using Python for log parsing.

Continue reading

How Do You Create A Dynamic List In Python?

Dynamic lists are an essential data structure in the programming world, but the way of defining and using dynamic lists is not always apparent to Python beginners. Years ago, when I first started learning Python ( while still working as a QA engineer ) I was in the same exact position as you, I was asking the same question: “How Do You Create A Dynamic List In Python?”. In this post, I’ll walk you through the ways of creating a dynamic list in Python based on my own experience.

How Do You Create A Dynamic List In Python?

There are several methods for creating a dynamic list in Python, including using the list() function, using square brackets [ ], and using the .append() method.

How Do You Create A Dynamic List In Python?
How Do You Create A Dynamic List In Python?
Continue reading

Should I Use Elif In Python?

When working on complex projects, you may encounter a situation where you need to make decisions based on multiple conditions. That’s one of the first things I got to know as a new QA engineer who later became a Python developer.

This is where the elif statement in Python comes in.

In this article, we’ll explore what the elif statement is, how it works, and when to use it in your code.

I’m going to answer the “Should I Use Elif In Python?” question based on my experience.

Continue reading

How Do I Store Python Logs In A File?

In many Python programming situations, at some point, as your application grows you want to start storing logs in a file. Since the very early days ( about my Python experience here ) that was the case for me. In this post, I’ll share my ideas for the “How Do I Store Python Logs In A File?” question.

How Do I Store Python Logs In A File?

One way to store these Python logs in a file so you can look at them later is to write them to a file using a built-in logging module. 

Here’s an example of how to use the logging module to store logs in a file in Python:

import logging

# Configure the logging module to use a file
logging.basicConfig(filename='example.log', level=logging.DEBUG)

# Write some log messages
logging.debug('This is a debug message')
logging.info('This is an info message')
logging.warning('This is a warning message')
logging.error('This is an error message')
logging.critical('This is a critical message')

In this example, the basicConfig() function is used to configure the logging module to write logs to a file named ‘example.log’.

The level argument is set to logging.DEBUG which means that all log messages, including debug, info, warning, error, and critical messages, will be written to the file.

Then the code uses different logging levels debug(), info(), warning(), error() and critical() to write different log messages.

When you run this code, it will create a new file called ‘example.log’ in the same directory as your script, and the log messages will be written to it.

Obviously, this is a very simplified version of logging in Python, I’ll get into more details and other examples in the following sections of this post.

Continue reading

What Is Python Programming In Short?

The first time you hear about Python Programming you kind of want to explore and understand the capabilities of the language. This is exactly what happened to me when one of my university professors told me about Python and I was just a QA engineer at that time. The first question that came to my mind was: “What Is Python Programming In Short?”. Let me explain…

What Is Python Programming In Short?

As a Python developer who has been using Python for several years now, I can confidently say that it is an incredibly powerful and versatile programming language.

Python is a high-level, interpreted language, which means that it is easy to read and write, and you don’t need to worry about low-level details like memory management and compiling code.

Python is great for beginners who never coded anything before.

I used to be one years ago and all I wanted to do was to just start building a script or a small project, just to start understanding programming from a practical standpoint, not just in theory.

Continue reading

What Is The Order To Learn Python?

Years ago, when I first got into learning Python (while I was still a QA engineer) I wasn’t sure about the order in which I should learn Python. So, what is the order to learn Python? Let’s look into the most common topics and questions people ask when it comes to learning Python properly.

What Is The Order To Learn Python?

As a Python developer with 7+ years of experience, I can say that it’s important for you as a beginner to learn Python in a specific order.

Start with the basic concepts of programming, such as the following:

  • Variables
  • Data types
  • Loops
  • Control structures

These will give you a solid foundation and understanding of fundamentals. From there, you can move on to:

  • Learning the syntax of Python
  • How to write and run programs
  • How to define and call functions
  • How to work with modules.
Continue reading

How Do I Search For A Pattern In Python?

A couple of years back when I was still a QA engineer (not a Python developer yet) I got myself into dozens of situations where I had to figure out how do I search for a pattern in Python.. A pattern in strings, a pattern in files, etc. Let’s look into possible solutions in this post.

How Do I Search For A Pattern In Python?

To search for a pattern in a string in Python, you can use the re module, which stands for regular expression. Regular expressions are a way to describe patterns in strings, and the re module provides several functions to work with them in Python.

Suppose you have a list of emails, and you want to extract the username and domain name from each email address.

The emails look like this:

jane.doe@example.com
john.smith@gmail.com

You can use the re module and regular expressions to extract the username and domain name from the email addresses like this:

import re

email = 'jane.doe@example.com'

# Extract the username and domain name using a regular expression
pattern = r'(.+)@(.+)'
match = re.search(pattern, email)

username = match.group(1)
domain = match.group(2)

print(f'Username: {username}')  # Output: 'Username: jane.doe'
print(f'Domain: {domain}')  # Output: 'Domain: example.com'

In this example, we used the re.search() function to find the first occurrence of the pattern in the email address, and then used the group() method to extract the matching substrings.

The regular expression itself uses several special characters to specify the pattern:

  • . matches any single character (except a newline)
  • + matches one or more occurrences of the preceding character
  • ( ) define a capturing group, which allows us to extract the matching substrings using the group() method
Continue reading