Square brackets next to the object. What did the designation mean?

What is the name of the square bracket syntax in this snippet?

And - just to clarify - is it accessing the default field inside the "label" and changing it?

It seems I think this is called “binding”, but I have no idea where I got this idea from

def change_text():
    label["text"] = entry.get()
+4
source share
2 answers

Depending on the context, it can be called:

  • receive / set item (e.g. dicts)
  • __getitem__/ __setitem__/ get-key / set-key (e.g. dicts)
  • indexing (for example, my_list [3])
  • slicing (for example, my_list [1: 3])
  • subscriptip (thanks, @AnotherTest)

"" : (label), ("text"), ( )...

+6
+6

Source: https://habr.com/ru/post/1531234/


All Articles