Tagged articles
Metaclass
19 articles · Page 1 of 1
This comprehensive guide explains what metaclasses are, why they matter, and how to use them for dynamic class creation, automatic registration, API enforcement, and ORM‑style frameworks, while comparing them to decorators and offering best‑practice tips and performance considerations.
DecoratorMetaclassOOP
0 likes · 14 min read

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.
EAFPMetaclassPython
0 likes · 8 min read

This article explains the relationships among Python’s type, object, and class constructs, demonstrates how to create classes with both type and class keywords, explores metaclasses, inheritance patterns, and essential object methods, providing clear code examples for each concept.
InheritanceMetaclassOOP
0 likes · 6 min read

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.
DecoratorDesign PatternMetaclass
0 likes · 10 min read

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.
DescriptorMROMetaclass
0 likes · 8 min read

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.
Design PatternMetaclasssingleton
0 likes · 5 min read

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.
DecoratorMetaclassadvanced
0 likes · 6 min read

This tutorial explains how to create a lightweight Python ORM without using metaclasses, covering the design of Field, Compare, Model, and Query classes, demonstrating insert and select operations, and extending query capabilities with LIMIT, OFFSET, GROUP BY, and HAVING.
MetaclassORMquery builder
0 likes · 9 min read

This article explains the purpose of the Singleton pattern, demonstrates multiple Python implementations—including module‑based, decorator, class‑based, __new__ method, and metaclass approaches—covers thread‑safety with locking, and provides complete code examples for each technique.
Design PatternMetaclasssingleton
0 likes · 10 min read

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.
Design PatternMetaclasssingleton
0 likes · 10 min read

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.
DecoratorDesign PatternLock
0 likes · 10 min read

This article demonstrates how to achieve Java hot‑update without rebuilding by leveraging Groovy's metaclass and GroovyShell, walking through a verification example, a full script implementation, and practical tips for handling script encoding issues.
GroovyGroovyShellJava
0 likes · 5 min read

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.
DynamicMethodFastjsonGroovy
0 likes · 4 min read

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.
GroovyMetaclassSpock
0 likes · 7 min read

This article explains the internal algorithm of Python's isinstance function, how it can be overloaded via __instancecheck__, the role of metaclasses, and provides concrete code examples and a step‑by‑step recreation of the check logic for better understanding of duck typing.
MetaclassPythonduck-typing
0 likes · 6 min read

This tutorial demystifies Python metaclasses by showing how the fundamental "Dao" concept maps to type, metaclass, class and instance, then walks through creating a dynamic ORM layer and a batch proxy‑crawling framework using those metaclasses.
MetaclassORMProxy
0 likes · 20 min read

This article explains three reliable ways to implement the singleton pattern in Python—using a class decorator, a custom metaclass with __call__, and overriding __new__—including complete code examples and a discussion of common pitfalls.
DecoratorDesign PatternMetaclass
0 likes · 5 min read

This tutorial explores Python metaclasses, demonstrating how to create dynamic classes, implement a lightweight ORM using metaclasses, and build a flexible proxy crawler with multiple site support, all illustrated with clear code examples and step‑by‑step explanations.
MetaclassORMProxy
0 likes · 17 min read

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.
MetaclassPythonType
0 likes · 6 min read
