We're sorry but this page doesn't work properly without JavaScript enabled. Please enable it to continue.
Feedback

How Python inserts 'self' into methods

Formale Metadaten

Titel
How Python inserts 'self' into methods
Untertitel
An accessible introduction to descriptors
Serientitel
Anzahl der Teile
637
Autor
Lizenz
CC-Namensnennung 2.0 Belgien:
Sie dürfen das Werk bzw. den Inhalt zu jedem legalen Zweck nutzen, verändern und in unveränderter oder veränderter Form vervielfältigen, verbreiten und öffentlich zugänglich machen, sofern Sie den Namen des Autors/Rechteinhabers in der von ihm festgelegten Weise nennen.
Identifikatoren
Herausgeber
Erscheinungsjahr
Sprache

Inhaltliche Metadaten

Fachgebiet
Genre
Abstract
When someone starts learning about classes in Python, one of the first things they'll come across is "self" in the parameter list of a method. To keep it simple, it's usually explained that Python will automatically pass the current instance as the first argument to the method: "self" will refer to the instance the method was called on. This high-level explanation really helps with keeping the focus on learning the basics of classes, but it also side-steps what is really going on: It makes it sound like process of inserting "self" is something automagical that the language just does for you. In reality, the mechanism behind inserting self isn't magical at all and it's something you can very much play with yourself. In this intermediate level talk, Sebastiaan Zeeff will take you down into the heart of the Python data model to explain how the mechanism behind inserting "self" works. He will talk about the descriptor protocol and how it allows you to modify how attributes are accessed, assigned, or deleted in Python. He hopes that understanding how descriptors work will demystify "self" in Python.