Zanurkuj w Pythonie/Metody specjalne: Różnice pomiędzy wersjami
Usunięta treść Dodana treść
Nie podano opisu zmian |
Nie podano opisu zmian |
||
Linia 1:
== Pobieranie i ustawianie elementów ==
Oprócz normalnych metod, jest te kilka metod specjalnych, które można definiować w klasach Pythona. Nie są one wywoływane bezpośrednio z Twojego kodu (jak zwykłe metody). Wywołuje je za Ciebie Python w określonych okolicznościach lub gdy użyjesz określonej składni.
As you saw in the previous section, normal methods go a long way towards wrapping a dictionary in a class. But normal methods alone are not enough, because there are a lot of things you can do with dictionaries besides call methods on them. For starters, you can get and set items with a syntax that doesn't include explicitly invoking methods. This is where special class methods come in: they provide a way to map non-method-calling syntax into method calls.
|