Greetings!
I’ve been coding for a while, and have been trying Python on and off for a few years now. I’ve re-started learning again, and have a question about the dot notation.
Is something like tag.something a function? If tag and something were defined as operations, would this tag.something do the different operations? Like calling a function?
Or is it like a table? I’ve been working with Lua, and the table systems ( table ={red}, table[1]=red) and this is clouding my insight a little bit.
Any help is appreciated!
Dot notation is called an “attribute” in Python. In other languages it
could be called a member, or an instance variable.
I’m not an expert in Lua, but if I recall correctly, Lua tables are very
similar to Python dicts (short for “dictionaries”). Behind the
scenes, Python objects use dicts as the storage for their attributes, so
in a manner of speaking, looking up an attribute like tag.something is
rather like looking up something in a table.
There is a very common kind of attribute called a “method” which is a
function. You can usually tell when something is a method, because it
gets called with round brackets (parentheses):
# upper is a method
result = mystring.upper()
but remember, a method like upper is also an attribute.