Tagged articles
4 articles
Page 1 of 1
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.

code-examplesmagic-methodsunittest
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 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.

boolcode-examplesint
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-methodsprogramming
0 likes · 7 min read
10 Most Common Python Magic Methods with Practical 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.

Debugging__invokeautoload
0 likes · 10 min read
Understanding PHP Magic Methods: __toString, __invoke, __set_state, __clone, __autoload, and __debugInfo