Tag

MagicMethods

0 views collected around this technical thread.

Test Development Learning Exchange
Test Development Learning Exchange
Nov 24, 2024 · Fundamentals

Common Python Magic Methods and Their Usage

This article introduces Python's most frequently used magic methods—including __new__, __init__, __str__, __add__, __len__, __getitem__, __setitem__, __delitem__, __contains__, __bool__, __iter__, comparison operators, arithmetic operators, and context manager methods—explaining their purpose, typical use cases, and providing clear code examples for each.

MagicMethodsProgrammingPython
0 likes · 11 min read
Common Python Magic Methods and Their Usage
Test Development Learning Exchange
Test Development Learning Exchange
Nov 25, 2023 · Fundamentals

Practical Examples of Python Iteration and Serialization Magic Methods

This article presents ten practical Python code examples demonstrating how to implement iteration and serialization magic methods, covering iterable objects, generators, indexed and sliced sequences, length, string and byte representations, as well as JSON, pickle, and XML serialization techniques.

CodeExamplesMagicMethodsPython
0 likes · 6 min read
Practical Examples of Python Iteration and Serialization Magic Methods
Test Development Learning Exchange
Test Development Learning Exchange
Aug 17, 2023 · Fundamentals

Python Comparison and Hash Magic Methods: Practical Code Examples

This article explains Python's comparison and hash magic methods with ten practical code snippets, covering equality, inequality, ordering, hash calculation, total_ordering simplification, custom object sorting, and using objects as dictionary keys, set elements, and memoization caches.

HashingMagicMethodsObjectOriented
0 likes · 7 min read
Python Comparison and Hash Magic Methods: Practical Code Examples
Test Development Learning Exchange
Test Development Learning Exchange
Aug 2, 2023 · Fundamentals

10 Practical Python Magic Method Examples for Iteration and Serialization

This article presents ten practical Python examples that demonstrate how magic methods can be used to implement iterable objects, support slicing and indexing, provide length, string and byte representations, and enable JSON, pickle, and XML serialization.

MagicMethodsPythonSerialization
0 likes · 6 min read
10 Practical Python Magic Method Examples for Iteration and Serialization
php中文网 Courses
php中文网 Courses
Jan 22, 2021 · Backend Development

Understanding Controller Instantiation, ArrayAccess, and Magic __get in the ThinkPHP Framework

This article provides a detailed walkthrough of how ThinkPHP instantiates controllers after route detection, explains the role of the Dispatch module, and compares the behavior of ArrayAccess versus the magic __get method for accessing container services, illustrating each step with code examples.

ArrayAccessMagicMethodsRouting
0 likes · 9 min read
Understanding Controller Instantiation, ArrayAccess, and Magic __get in the ThinkPHP Framework