Python __aenter__() Magic Method

object.__aenter__(self) 💡 Summary: Python’s __aenter__() magic method is semantically identical to __enter__() but is used for asynchronous and parallel programming. Python calls the __aenter__() magic method when starting an async with block whereas the __aexit__() method is called when leaving it. An object that implements both __aenter__() and __aexit__() methods is called an asynchronous context … Read more

How to Deploy a Smart Contract to Polygon in Brownie

This article will look at deploying a smart contract to Polygon using Brownie.  What is Polygon? Polygon is “a protocol and a framework for building and connecting Ethereum-compatible blockchain networks” (https://polygon.technology/). It started as Matic Network in 2017 to solve Ethereum’s scalability and user experience issues by using an ​off/side chain scaling solution. In 2021, … Read more

¿Cómo instalar una biblioteca en PyCharm?

Planteamiento del problema: Dado un proyecto de PyCharm. ¿Cómo instalar una biblioteca en tu proyecto dentro de un entorno virtual o de forma global? Solución que siempre funciona: Abre File > Settings > Project en el menú de PyCharm. Selecciona el proyecto actual. Haz clic en la pestaña Python Interpreter dentro de la pestaña del … Read more

Python __exit__() Magic Method

object.__exit__(self, exc_type, exc_value, traceback) 💡 Summary: Python calls the __exit__() magic method when ending a with block whereas the __enter__() method is called at the start. An object that implements both __exit__() and __enter__() is called a context manager. By defining those methods, you can create your own context manager. We define a custom class … Read more

Python __enter__() Magic Method

object.__enter__(self) 💡 Summary: Python calls the __enter__() magic method when starting a with block whereas the __exit__() method is called at the end. An object that implements both __enter__() and __exit__() methods is called a context manager. By defining those methods, you can create your own context manager. We define a custom class MySecretConnection. This … Read more

Python __format__() Magic Method

Syntax object.__format__(self, spec) The Python __format__() method implements the built-in format() function as well as the string.format() method. So, when you call format(x, spec) or string.format(spec), Python attempts to call x.__format__(spec). The return value is a string. We call this a “Dunder Method” for “Double Underscore Method” (also called “magic method”). To get a list … Read more

Python __set_name__() Magic Method

Python’s magic method obj.__set_name__(self, owner, name) method is created on an attribute obj when the class owner holding the attribute is created. We call this a “Dunder Method” for “Double Underscore Method” (also called “magic method”). To get a list of all dunder methods with explanation, check out our dunder cheat sheet article on this … Read more

­­Pandas DataFrame Missing Data Handling – backfill(), bfill(), fillna(), dropna(), and interpolate()

The Pandas DataFrame/Series has several methods to handle Missing Data. When applied to a DataFrame/Series, these methods evaluate and modify the missing elements. This is Part 11 of the DataFrame methods series: Part 1 focuses on the DataFrame methods abs(), all(), any(), clip(), corr(), and corrwith(). Part 2 focuses on the DataFrame methods count(), cov(), … Read more