Reputation: 1134
What's the name for the square brackets syntax in this snippet?
And - just to clarify - is it accessing the default field inside 'label' and changing that?
I seem to think it is called 'binding' - but I've got literally no idea where I got that idea from
def change_text():
label["text"] = entry.get()
Upvotes: 5
Views: 419
Reputation: 32429
In the python grammar it can be summarized as "subscripting".
The python doc calls it "subscription".
Upvotes: 6
Reputation: 64298
Depending on the context, it can be referred to as:
__getitem__
/ __setitem__
/ get-key / set-key (e.g. dicts)By "context" I mean: the type of the object (label
), the type of the object inside the brackets ("text"
), whether the square brackets are in the right-hand-side or left (get or set)...
Upvotes: 6