Python Basics Classes Dunder __add__ __matmul__ __getitem__

Publié le: 10 juin 2026
sur la chaîne: Stephen Blum
53
6

Today we are wrapping up a few Python basics with two dunder methods. First is __add__, so when you add two objects, you can return a new one with combined data, like a name made from self.name plus other.name. Then we look at the matrix multiply operator, the at symbol, which uses __matmul__.

It is weird that Python uses double underscores, but that is how the language marks special methods. The cool part is the power: you can overload operators and make your classes act like built in types. While building matrix multiplication by hand, we hit a common bug: list indices must be integers, not lists, so you often need enumerate when you want indexes.

Most of the time you would use NumPy, but writing it once helps you understand what is really happening.


Sur cette page du site, vous pouvez voir la vidéo en ligne Python Basics Classes Dunder __add__ __matmul__ __getitem__ durée heure minute seconde en bonne qualité , qui a été Téléchargé par l'utilisateur Stephen Blum 10 juin 2026, Partagez le lien avec vos amis et connaissances, sur youtube cette vidéo a déjà été regardée 53 fois et il a aimé 6 téléspectateurs. Bon visionnage!