Rajendra Dharmkar has Published 189 Articles

How to subtract Python timedelta from date in Python?

Rajendra Dharmkar

Rajendra Dharmkar

Updated on 28-Aug-2025 12:15:29

11K+ Views

The Python datetime module provides various ways for manipulating dates and times. One of its key features is the timedelta object, which represents duration and also the difference between two dates or times. Subtracting a specific amount of time from a date can be done using timedelta. For example, if ... Read More

How to write a regular expression to match either a or b in Python?

Rajendra Dharmkar

Rajendra Dharmkar

Updated on 28-Aug-2025 12:12:51

5K+ Views

In Python regular expressions, one of the common tasks is matching either one character or another. we can done this easily by using the re module along with the pipe symbol |, which acts as an OR operator. In this article, we’ll explore how to match either 'a' or ... Read More

Why do I get different timestamps in python on different machines?

Rajendra Dharmkar

Rajendra Dharmkar

Updated on 28-Aug-2025 11:55:32

262 Views

A timestamp represents a specific point in time as a numerical value. It typically measures the number of seconds that have elapsed since the Unix epoch, which is January 1, 1970, at 00:00:00 Coordinated Universal Time (UTC). The main reasons behind timestamp variations on different machines include differences in time ... Read More

How to convert a datetime string to millisecond UNIX time stamp?

Rajendra Dharmkar

Rajendra Dharmkar

Updated on 28-Aug-2025 11:52:42

1K+ Views

A millisecond UNIX timestamp is a number that shows how many milliseconds have elapsed since the beginning of the Unix epoch, which is January 1, 1970, at 00:00:00 Coordinated Universal Time (UTC) up to the current moment or specified date and time. Instead of counting time in days, hours, or ... Read More

How to match anything except space and new line using Python regular expression?

Rajendra Dharmkar

Rajendra Dharmkar

Updated on 28-Aug-2025 11:48:56

1K+ Views

Python's re module provides various tools for pattern matching using regular expressions (regex). With the help of regex, we can define flexible patterns that match or exclude particular characters or sequences. In this article, we will focus on how to match everything except spaces and newlines using regular expressions. The ... Read More

How to compare Python DateTime with Javascript DateTime?

Rajendra Dharmkar

Rajendra Dharmkar

Updated on 28-Aug-2025 11:44:15

812 Views

Both Python and JavaScript have unique ways of representing date and time data. To compare Python datetime objects with JavaScript Date objects, we must ensure that both are converted to a common format, such as ISO 8601 strings or Unix timestamps (milliseconds since epoch). The following are two major differences ... Read More

What are metacharacters inside character classes used in Python regular expression?

Rajendra Dharmkar

Rajendra Dharmkar

Updated on 28-Aug-2025 11:42:12

459 Views

Python's regular expressions provide various ways to search and manipulate strings. They are used to define search patterns that can be matched in text data. These patterns are defined using a set of characters known as metacharacters, which carry special meaning in regex. Their behaviour can change when used inside ... Read More

What are character class operations in Python?

Rajendra Dharmkar

Rajendra Dharmkar

Updated on 28-Aug-2025 11:09:56

2K+ Views

Character class operations in Python's regular expressions allow us to define set of characters we want to match. Instead of searching for one specific character, we can search for any character within that set. A character class in regex is written using square brackets []. It defines a group of ... Read More

How to check whether a string ends with one from a list of suffixes in Python?

Rajendra Dharmkar

Rajendra Dharmkar

Updated on 02-Jun-2025 17:30:08

970 Views

A suffix is a group of letters added at the end of a word. In Python, we can check if a string ends with any one of multiple suffixes using the endswith() method. It takes a tuple of suffixes as an argument and returns True if the string ends ... Read More

How to handle invalid arguments with argparse in Python?

Rajendra Dharmkar

Rajendra Dharmkar

Updated on 02-Jun-2025 17:29:49

2K+ Views

Argparse is a Python module that helps you create easy-to-use command-line interfaces. When building these interfaces, it is important to handle invalid arguments properly to give clear feedback to users and prevent your program from crashing unexpectedly. There are several ways to handle invalid arguments in argparse. You can ... Read More

1 2 3 4 5 ... 19 Next
Advertisements