Python __next__() Magic Method

Syntax object.__next__(self) The Python __next__ method returns an arbitrary element that represents the “next” element when you iterate over the object on which it is called. For example, if you iterate over my_object using for x in my_object, Python internally calls my_object.__next__() in each loop iteration to determine the next element. Formally, the __next__() method … Read more

Python __len__() Magic Method

Syntax object.__len__(self) The Python __len__ method returns a positive integer that represents the length of the object on which it is called. It implements the built-in len() function. For example, if you call len(x) an object x, Python internally calls x.__len__() to determine the length of object x. We call this a “Dunder Method” for … Read more

Create Web Frontend using Brownie react-mix

In this article, we continue exploring the functionality of Brownie, a smart contract development and testing framework for Solidity and Vyper. We created a simple smart contract in the previous tutorials and deployed it to the Ropsten testnet. Please check the following articles if you haven’t done so. Brownie – Smart Contracts in Python How … Read more

[FIXED] AttributeError: ‘NoneType’ object has no attribute ‘something’

Introduction Problem: How to solve “AttributeError: ‘NoneType’ object has no attribute ‘something’ “? An AttributeError is raised in Python when you attempt to call the attribute of an object whose type does not support the method. For example, attempting to utilize the append() method on a string returns an AttributeError as lists use the append() … Read more

Python Dijkstra Algorithm

You can download the PDF file of the presentation here. Also, watch the presentation as a Gif here: What is Dijkstra’s Algorithm? Dijkstra’s algorithm solves the single-source shortest path (SSSP) problem. Generally, it enables finding the shortest route between two vertices in a graph. Its author is dr. Edsger W. Dijkstra, a pioneering contributor to … Read more

Python Math Module – 5 Combinatorial Functions Ever Coder Ought to Know

This is the second article discussing the math module from the Python Standard Library. You can find the first about four basic numerical functions here. The articles are organized thematically; functions that are closely related to each other are discussed in the same article. In this article, we will explore two themes: combinatorics and elementary … Read more

Python __str__()

Syntax object.__str__(self) The Python __str__ method returns a string representation of the object on which it is called. For example, if you call print(x) an object x, Python internally calls x.__str__() to determine the string representation of object x. This method is also used to implement the built-in str() function. We call this a “Dunder … Read more

[SOLVED] ValueError: invalid literal for int() with base 10

[toc] Introduction Problem: How to fix “ValueError: invalid literal for int() with base 10“? In Python, you can convert the values of one type into another. That means you can convert the integer strings into integers, integers into floats, floats into strings, etc. But one such conversion that Python dislikes is to change a float … Read more

Pandas DataFrame Methods

The Pandas DataFrame is a data structure that organizes data into a two-dimensional format. If you are familiar with Excel or Databases, the setup is similar. Each DataFrame contains a schema that defines a Column (Field) Name and a Data Type.   This article delves into the methods available for DataFrame Iteration. This article also … Read more

Common Consensus Mechanisms in Blockchains

We know what a blockchain is and its wide applications. Blockchain is a distributed computing technology involving multiple nodes distributed across geographies. The problem is to ensure that each node gets the exact copy of the data. Hence, some protocol is needed to achieve this unison or consensus. This post tries to cover the need … Read more