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()
The notation may be a little confusing, but just remember that square brackets mean the end point is included, and round parentheses mean it's excluded. If both end points are included the interval is said to be closed, if they are both excluded it's said to be open.
Dot notation is one way to access a property of an object. To use dot notation, write the name of the object, followed by a dot (.), followed by the name of the property. Example: var cat = { name: 'Moo', age: 5, }; console.
Square brackets, often just called brackets in American English, are a set of punctuation marks that are most often used to alter or add information to quoted material. Square brackets come in pairs as [ and ].
Generally, 'parentheses' refers to round brackets ( ) and 'brackets' to square brackets [ ]. However, we are more and more used to hearing these referred to simply as 'round brackets' or 'square brackets'. Usually we use square brackets - [ ] - for special purposes such as in technical manuals.
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)...
In the python grammar it can be summarized as "subscripting".
The python doc calls it "subscription".
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With