I often see notes that e.g. []
is syntactic sugar for _getitem_
(Why/How does Pandas use square brackets with .loc and .iloc?), but neither by web search, not here on SO, not in glossary in docs.python.org I could find list of all sugars for Python. Are sugars official or left to each implementation specifics?
Asked
Active
Viewed 105 times
0

Alex Martian
- 3,423
- 7
- 36
- 71
-
1https://docs.python.org/3/reference/datamodel.html#special-method-names – Vaibhav Vishal Sep 10 '19 at 08:43
1 Answers
1
It's documented in the Python data model documentation. It's not exactly synthetic sugar, and more of an implementation detail of how container types work. Python has lots of these so-called "magic methods"

äymm
- 411
- 4
- 14
-
1thank you! I've found _getitem_ in pandas source https://github.com/pandas-dev/pandas/blob/master/pandas/core/indexing.py and now understand who it is working. – Alex Martian Sep 10 '19 at 09:21