Tag

Magic Methods

0 views collected around this technical thread.

php中文网 Courses
php中文网 Courses
Apr 1, 2025 · Fundamentals

Understanding Python Magic (Dunder) Methods

This article explains Python's magic (dunder) methods, categorizing them by purpose—construction, representation, comparison, arithmetic, container behavior, callability, and context management—and provides clear code examples illustrating how to customize class behavior for more Pythonic, intuitive objects.

Dunder MethodsMagic MethodsPython
0 likes · 11 min read
Understanding Python Magic (Dunder) Methods
Python Programming Learning Circle
Python Programming Learning Circle
Mar 19, 2025 · Fundamentals

Understanding Python Magic Methods: A Comprehensive Guide

This article explains Python's magic (dunder) methods, detailing their purpose, common special methods for initialization, comparison, arithmetic, container protocols, and other operations, and provides a practical code example to illustrate how they enable custom class behavior.

Code ExampleDunderMagic Methods
0 likes · 6 min read
Understanding Python Magic Methods: A Comprehensive Guide
Test Development Learning Exchange
Test Development Learning Exchange
Oct 30, 2024 · Fundamentals

Understanding Python Magic (Dunder) Methods: Definitions, Examples, and Best Practices

This article explains Python magic (dunder) methods, their purposes, common examples such as __init__, __str__, __repr__, __len__, __getitem__, __setitem__, __delitem__, __iter__, __call__, __add__, __eq__, __hash__, and shows how to implement operator overloading, iterator and context‑manager protocols while discussing naming rules, performance, inheritance, type checking, and limitations.

Context ManagerIterator ProtocolMagic Methods
0 likes · 19 min read
Understanding Python Magic (Dunder) Methods: Definitions, Examples, and Best Practices
Test Development Learning Exchange
Test Development Learning Exchange
Aug 19, 2024 · Fundamentals

Applying Python Magic Methods in Unit Tests: __init__, setUp, tearDown, __str__, __repr__, __eq__, __lt__, __len__, __iter__, __getitem__

This article explains how Python's magic (special) methods such as __init__, setUp, tearDown, __str__, __repr__, __eq__, __lt__, __len__, __iter__, and __getitem__ can be leveraged within unittest test cases to customize initialization, setup, cleanup, representation, comparison, length, iteration, and indexing, accompanied by concrete code examples.

Magic MethodsPythonTesting
0 likes · 7 min read
Applying Python Magic Methods in Unit Tests: __init__, setUp, tearDown, __str__, __repr__, __eq__, __lt__, __len__, __iter__, __getitem__
Test Development Learning Exchange
Test Development Learning Exchange
Aug 5, 2024 · Backend Development

Python Magic Methods: A Comprehensive Guide

This article introduces Python's magic methods, explaining their roles in object-oriented programming, including __init__, __str__, __len__, and more, with practical code examples and outputs.

Magic MethodsOOPTutorial
0 likes · 11 min read
Python Magic Methods: A Comprehensive Guide
Test Development Learning Exchange
Test Development Learning Exchange
Aug 3, 2024 · Fundamentals

Understanding Python Magic Methods: __bool__, __int__, __float__, __complex__, __index__, __oct__, __hex__, and __dir__

This article explains Python's special (magic) methods such as __bool__, __int__, __float__, __complex__, __index__, __oct__, __hex__, and __dir__, describing their purpose, how they affect object behavior, and provides concrete code examples demonstrating their usage and output.

Magic MethodsPythonSpecial Methods
0 likes · 5 min read
Understanding Python Magic Methods: __bool__, __int__, __float__, __complex__, __index__, __oct__, __hex__, and __dir__
Test Development Learning Exchange
Test Development Learning Exchange
Jul 18, 2024 · Fundamentals

10 Most Common Python Magic Methods with Practical Examples

This article introduces ten of the most frequently used Python magic (dunder) methods, explains their purpose, and provides clear code examples for __init__, __str__, __repr__, __add__, __len__, __getitem__, __setitem__, __iter__, __next__, __call__, __enter__, __exit__, __getattr__, __setattr__, and __new__, helping readers master Python’s special syntax.

DunderMagic MethodsOOP
0 likes · 7 min read
10 Most Common Python Magic Methods with Practical Examples
Test Development Learning Exchange
Test Development Learning Exchange
Dec 13, 2023 · Fundamentals

Understanding Python Magic (Special) Methods with Practical Examples

This article explains Python's magic (special) methods such as __init__, __str__, __getitem__, __setitem__, __len__, __eq__, __iter__, __next__, __enter__, __exit__, __call__, and __del__, providing clear descriptions and runnable code examples for each in Python programming.

Magic MethodsOOPPython
0 likes · 5 min read
Understanding Python Magic (Special) Methods with Practical Examples
php中文网 Courses
php中文网 Courses
Sep 25, 2023 · Backend Development

Advanced PHP Features: Magic Methods, Type Hints, Closures, Namespaces, Generators, Iterators, Date/Time, Regex, and Variable Scope

This article provides a comprehensive guide to advanced PHP features, covering magic methods, type hints, closures, namespaces, generators, iterators, date/time handling, regular expressions, and variable scope, each explained with clear descriptions and practical code examples for backend developers.

Backend DevelopmentClosuresGenerators
0 likes · 18 min read
Advanced PHP Features: Magic Methods, Type Hints, Closures, Namespaces, Generators, Iterators, Date/Time, Regex, and Variable Scope
php中文网 Courses
php中文网 Courses
Aug 24, 2023 · Backend Development

Accessing Private Members in PHP with __get(), __set() and ArrayAccess

This article explains why PHP throws "attempt to access private member" errors, describes the visibility keywords public, protected, private, and demonstrates how to use the magic methods __get() and __set() as well as the ArrayAccess interface to read and write private properties from outside the class.

ArrayAccessMagic MethodsPHP
0 likes · 5 min read
Accessing Private Members in PHP with __get(), __set() and ArrayAccess
Test Development Learning Exchange
Test Development Learning Exchange
Aug 3, 2023 · Fundamentals

Practical Python Comparison and Hashing Magic Methods – 10 Code Examples

This article presents ten practical Python code examples demonstrating how to implement and use comparison and hashing magic methods such as __eq__, __ne__, __lt__, __hash__, and related utilities like functools.total_ordering and memoization for custom objects.

HashingMagic Methodscomparison
0 likes · 7 min read
Practical Python Comparison and Hashing Magic Methods – 10 Code Examples
Laravel Tech Community
Laravel Tech Community
Jun 25, 2023 · Backend Development

Understanding PHP Magic Methods: __toString, __invoke, __set_state, __clone, __autoload, and __debugInfo

This article explains the purpose, usage, constraints, and example code for several PHP magic methods—including __toString, __invoke, __set_state, __clone, __autoload, and __debugInfo—showing their effects, common pitfalls, and how they improve object handling and debugging in modern PHP applications.

AutoloadMagic MethodsPHP
0 likes · 10 min read
Understanding PHP Magic Methods: __toString, __invoke, __set_state, __clone, __autoload, and __debugInfo
Laravel Tech Community
Laravel Tech Community
Jun 20, 2023 · Backend Development

Understanding PHP Magic Methods: Constructors, Destructors, Call, CallStatic, Get, Set, Isset, Unset, Sleep and Wakeup

This article explains the purpose, declaration syntax, usage rules, and practical examples of PHP's magic methods—including __construct, __destruct, __call, __callStatic, __get, __set, __isset, __unset, __sleep, and __wakeup—providing clear code snippets and output demonstrations for each.

Magic MethodsOOPPHP
0 likes · 16 min read
Understanding PHP Magic Methods: Constructors, Destructors, Call, CallStatic, Get, Set, Isset, Unset, Sleep and Wakeup
php中文网 Courses
php中文网 Courses
Jun 27, 2022 · Backend Development

Understanding PHP Magic Methods: Definitions and Use Cases

This article explains PHP's magic methods—functions prefixed with double underscores—detailing each method’s purpose such as constructors, destructors, property accessors, call handlers, serialization hooks, cloning, and debugging, providing a concise reference for backend developers.

Backend DevelopmentMagic MethodsOOP
0 likes · 4 min read
Understanding PHP Magic Methods: Definitions and Use Cases
Python Programming Learning Circle
Python Programming Learning Circle
Apr 19, 2021 · Fundamentals

Understanding Python Magic (Dunder) Methods

This article explains Python's built‑in magic (dunder) methods—functions that start and end with double underscores—showing how they enable custom class behavior such as indexing, iteration, string representation, callable objects, context management, object creation, and attribute handling with clear code examples.

Callable ObjectsContext ManagersDunder
0 likes · 14 min read
Understanding Python Magic (Dunder) Methods
php中文网 Courses
php中文网 Courses
Mar 12, 2021 · Backend Development

Understanding PHP Magic Methods: __construct, __destruct, __call, and More

This article explains the purpose, behavior, and typical usage of PHP's magic methods—including __construct, __destruct, __call, __callStatic, __get, __set, __isset, __unset, __sleep, __wakeup, __toString, __invoke, __set_state, __clone, __autoload, and __debugInfo—providing clear definitions, explanations, and code examples for each.

Magic MethodsPHP8Tutorial
0 likes · 7 min read
Understanding PHP Magic Methods: __construct, __destruct, __call, and More