0

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?

Alex Martian
  • 3,423
  • 7
  • 36
  • 71

1 Answers1

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
  • 1
    thank 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