I'm trying to explore the Kivy API and I'm very confused by some code lines I found in their multitexture example. One line of code seems to assign a value of "1" to a key of "texture0" in "self.canvas", treating "self.canvas" as though it is a python dictionary.
That code is self.canvas['texture0'] = 1
However, when I step past this line the debugger, I see no such entry in self.canvas, and self.canvas is of type "RenderContext". In fact, I see nothing that indicates that the statement changed anything observable in the debugger, but if I evaluate self.canvas['texture0']
, it evaluates to "1".
Where is this value being stored? I also can't find any clues in the Kivy's canvas docs
treating "self.canvas" as though it is a python dictionary.
This has nothing particularly to do with dictionaries, using the [] notation just calls __getitem__
or __setitem__
- see the Python docs. As it happens the class is in this case storing the data in an internal dictionary, but that's an implementation detail, not something required by this syntax.
However, when I step past this line the debugger, I see no such entry in self.canvas
The canvas objects are defined in cython, and the internal state attributes used for this storage are not visible to the Python code.