Python Dictionary pop() Method

This Python article covers the Python dictionary pop() method, specifically, its definition, syntax, parameter(s), and return type. Additionally, we’ll provide some examples on how dict.pop() is used in practice. So, let’s get started! πŸ™‚ Related Article: Python Dictionary Methods Definition The dict.pop() method both removes and returns a specified (key-value) pair element from a dictionary. … Read more

Brownie – Smart Contracts in Python

This is an introductory article to Brownie, a smart contract development and testing framework for Solidity and Vyper, especially with Python developers in mind.  We first start with the installation process and then create a project with a simple smart contract. We will look at how to interact with the smart contract on a local … Read more

Saleor – Create Your First Storefront App in Python

Quick Overview Saleor is a full-fledged e-commerce platform, and it has features including the management of customers, orders, products, shipping, site administration, among others. Saleor was built using Python and the Django Framework and uses a GraphQL API. It is a headless system, which means that it can be used with different types of front-end … Read more

Working with date-time in Pandas

In this article, we will see how to work with date-time in Pandas. We will learn how to convert strings into date-time objects, how to create date ranges in various ways, how to work with absolute time units, and how to restructure our date values using several Pandas functions. Why work with date-time? Before we … Read more

Python __eq__ Magic Method

To customize the behavior of the equality operator x == y, override the __eq__() dunder method in your class definition. Python internally calls x.__eq__(y) to compare two objects using x == y. If the __eq__() method is not defined, Python will use the is operator per default that checks for two arbitrary objects whether they … Read more

Python __div__() Magic Method

The Python __div__() magic method overrides the division operation for a custom object in Python 2. In Python 3, it was replaced by the __truediv__() for a / b and __floordiv__() dunder methods for a // b. The Python __truediv__() method is called to implement the normal division operation / called true division. For example … Read more

The Sieve of Eratosthenes in Python

Finding prime numbers is of critical importance for practical applications such as cryptography. Many public-key methods are only safe from a cryptographic point of view because it’s generally inefficient and slow to compute the prime factors of large numbers. As you go over the article, feel free to watch my explainer video on the Sieve … Read more

Python Input/Output – JSON

Over your career as a Data Scientist, there may be instances where you will work with data to/from a DataFrame to JSON format. This article shows you how to manipulate this data using the above functions. This article covers the commonly used parameters for each function listed above. For a complete list of all parameters … Read more

Python __invert__() Magic Method

Syntax object.__invert__(self) The Python __invert__() method implements the unary arithmetic operation bitwise NOT ~. So, when you cal ~x, Python will internally call x.__invert__() to obtain the inverted object. If the method is not implemented, Python will raise a TypeError. We call this a “Dunder Method” for “Double Underscore Method” (also called “magic method”). To … Read more