Tag

metaclass

1 views collected around this technical thread.

Code Mala Tang
Code Mala Tang
Apr 6, 2025 · Fundamentals

Why Overusing isinstance() Makes Python Code Rigid – Better Practices

This article explains why relying heavily on Python's isinstance() for type checking leads to less flexible code, introduces the EAFP vs. LBYL philosophies, and shows when isinstance() is appropriate through clear examples and best‑practice guidelines.

Best PracticesEAFPduck typing
0 likes · 8 min read
Why Overusing isinstance() Makes Python Code Rigid – Better Practices
Python Programming Learning Circle
Python Programming Learning Circle
Nov 5, 2024 · Fundamentals

Implementing the Singleton Pattern in Python: Multiple Approaches and Thread Safety

This article explains the Singleton design pattern in Python, covering various implementation methods—including modules, decorators, classic classes, __new__ method, and metaclasses—while demonstrating thread‑safety concerns and solutions with locking, and provides complete code examples for each approach.

ModuleThread Safetydecorator
0 likes · 10 min read
Implementing the Singleton Pattern in Python: Multiple Approaches and Thread Safety
Test Development Learning Exchange
Test Development Learning Exchange
Sep 24, 2024 · Fundamentals

Understanding Python super() and Method Resolution Order (MRO) with Advanced Examples

This article explains how Python's super() works by invoking the next class in the Method Resolution Order (MRO), demonstrates MRO behavior with multiple inheritance examples, and presents advanced techniques such as metaclasses, descriptors, class decorators, __slots__, and singleton patterns.

MROMultiple Inheritanceadvanced OOP
0 likes · 8 min read
Understanding Python super() and Method Resolution Order (MRO) with Advanced Examples
Test Development Learning Exchange
Test Development Learning Exchange
May 27, 2024 · Fundamentals

Implementing the Singleton Pattern in Python: Multiple Approaches

This article explains the Singleton design pattern in Python and presents seven implementation techniques—including module‑level variables, module instances, decorators, metaclasses, class methods, and thread‑safe approaches—complete with code examples and guidance on choosing the appropriate method.

Thread Safetydesign patternmetaclass
0 likes · 5 min read
Implementing the Singleton Pattern in Python: Multiple Approaches
Test Development Learning Exchange
Test Development Learning Exchange
Apr 13, 2024 · Fundamentals

Advanced Python Techniques: 10 In-Depth Code Examples

This article presents ten advanced Python techniques—including list comprehensions, lambda functions, decorators, context managers, generators, metaclasses, asyncio coroutines, enums, slicing, and exception handling—each illustrated with detailed code examples to help readers deepen their mastery of Python programming.

AdvancedGeneratorasyncio
0 likes · 6 min read
Advanced Python Techniques: 10 In-Depth Code Examples
Python Programming Learning Circle
Python Programming Learning Circle
May 13, 2023 · Fundamentals

Implementing the Singleton Pattern in Python: Modules, Decorators, Classes, __new__ Method, and Metaclasses

This article explains the Singleton design pattern in Python, describing why a single instance may be needed, and demonstrates five implementation techniques—including module-level singletons, decorators, class methods, the __new__ method, and metaclasses—while addressing thread‑safety concerns with locking mechanisms.

Thread Safetydesign patternmetaclass
0 likes · 10 min read
Implementing the Singleton Pattern in Python: Modules, Decorators, Classes, __new__ Method, and Metaclasses
Python Programming Learning Circle
Python Programming Learning Circle
Aug 10, 2022 · Fundamentals

Implementing Thread‑Safe Singleton Pattern in Python

This article explains the purpose of the Singleton design pattern, demonstrates multiple Python implementations—including module‑level singletons, decorators, class‑based approaches, __new__ method, and metaclass techniques—and shows how to add thread‑safety with locks to ensure only one instance exists across concurrent executions.

LockThread Safetydecorator
0 likes · 10 min read
Implementing Thread‑Safe Singleton Pattern in Python
FunTester
FunTester
Oct 28, 2021 · Backend Development

Adding Custom Methods to fastjson JSONObject Using Groovy MetaClass

This article demonstrates how to dynamically add custom methods to fastjson's JSONObject in Groovy by leveraging MetaClass and closures, providing code examples that simplify JSON traversal and output during API testing for developers.

DynamicMethodGroovyJSONObject
0 likes · 4 min read
Adding Custom Methods to fastjson JSONObject Using Groovy MetaClass
FunTester
FunTester
Oct 22, 2021 · Backend Development

Using Groovy MetaClass to Dynamically Add Methods and Properties to Classes and Objects

This article demonstrates how Groovy's MetaClass can be used at runtime to add object methods, static methods, and properties to classes, and includes a complete Spock unit‑test example that verifies dynamic behavior with detailed code snippets and console output.

GroovySpockdynamic programming
0 likes · 7 min read
Using Groovy MetaClass to Dynamically Add Methods and Properties to Classes and Objects
Qunar Tech Salon
Qunar Tech Salon
May 26, 2016 · Fundamentals

Understanding Python Metaclasses: Objects, Types, and Custom Class Creation

This article explains Python’s object model, showing that everything—including classes—is an object, describing how the built‑in type function serves as a metaclass, and demonstrating custom metaclass creation and practical examples such as subclass tracking and final class enforcement.

custom class creationmetaclassobject-oriented
0 likes · 6 min read
Understanding Python Metaclasses: Objects, Types, and Custom Class Creation