2024-08-26 –, Room 5
Welcome to this tutorial on Python's magic methods, often underestimated or overlooked in programming practice. And yet, magic methods make it easy to write code that implements often very complex algorithms in a readable way.
In this tutorial, we will learn how to create and use magic methods and talk about some interesting non-trivial magic methods.
This tutorial will have classroom exercises, post class homeworks as well as complimentary readings. All the presentation, code, exercises will be shared in advance (~ 2 - 3 days) and the solutions of the exercise will be shared after the tutorial is completed.
Python allows you to equip created classes with special methods, also known as magic methods or dunder methods. To recognize a special method, you should know that it is a method whose name begins and ends with a double underscore. But it's not the name that their magic lies in, because these methods have a special meaning for Python.
Python calls magic methods in response to fundamental operations, such as creating class instances, indexing sequences, comparing objects, managing attribute access, and more, so knowing how to create them is fundamental for any Pythonista.
During this tutorial, you’ll:
- Find out what Python magic methods are,
- Understand the magic behind Python magic methods,
- Customize various behaviors of classes using magic method.
To fully benefit from this tutorial, you should be familiar with object-oriented programming in Python.
Tutorial on Python magic methods at EuroSciPy 2024
Category [High Performance Computing]:Parallel Computing
Category [Community, Education, and Outreach]:Learning and Teaching Scientific Python
Category [Machine and Deep Learning]:Supervised Learning
Category [Scientific Applications]:Astronomy
Category [Data Science and Visualization]:Data Analysis and Data Engineering
Expected audience expertise: Domain:none
Expected audience expertise: Python:some
Paweł Żal - software developer, system architect with 20 years of experience in IT. A proponent of distributed solutions, recently fascinated by time series databases. An avid kayaker and tinkerer.