PythonPython How to add custom fields to logging formatter logging module is a useful module for logging. The log format somehow needs to be defined to make it more readable. The ...2023.11.22Python
PythonPython How to convert a nested JSON to a class It's easy to convert an object to JSON and JSON to an object in Python. json module provides the following functions. du...2023.10.20Python
PythonPython How to pass a class constructor as an argument Is it possible to pass a constructor as a parameter? Yes, it is. There are multiple ways to instantiate a different clas...2023.08.14Python
PythonPython How to mock constructor with mockito for unit testing A class constructor directly needs to be called in a class in some cases. It might not be a good design but sometimes it...2023.08.09Python
PythonPython How to handle an error from finally block If an error occurs in finally block, the first error caught in except block is overwritten. How can we know both errors? Let's split the block and add both errors into one custom error.2023.08.07Python
PythonPython Find the fastest way to access a property for performance Which structure is the fastest way to access a property? Let's compare the different structures and choose the fastest one for performance tuning.2023.07.10Python
PythonPython How to run another Python script with arguments Another Python script can be run by exec function. However, arguments can't be specified with it. How is it implemented? Okay, use subprocess.call or subprocess.run instead.2023.04.05Python
PythonPython How do nested groups work for regex If there are several formats and data need to be extracted from the string, the nested group might neet to be used in the regex string. How does it actually work? Let's check together with me.2023.03.27Python
PythonPython Convert str to int/float, dict/list to str, and vice versa Conversion is often needed to change the data type. This post covers main cases where you need in your production code. Let's check how to convert a variable.2023.03.24Python
PythonPython Access a class property by the name without dot chaining In some cases, a key string needs to be used to read property. How can it be done in Python? Use setattr, getattr, and hasattr functions2023.03.20Python