Thatâs not very under-the-hood though is it?
An expression describes a value
so for example the expression
1
evaluates to 1
similarly, a function
f
evaluates to ⌠f
What would you do with a function? Call it, presumably. You now have a different expression, you did something with f
f()
The result is whatever f returns, and f probably returned something other than itself (though it could, nothing stopping it from doing so)
So when youâre deciding whether or not to call something ⌠did you want the thing itself, or its return value?
The dots in your expressions arenât any different from your parenthesis, you could omit those as well, they too, are operations on values
x.something
asks x for its something attribute
x
doesnât, thatâs x itself
so, if you have some value, then, what operations does that support, and which operations do you want to do to it? you wouldnât pick operations at random would you? or if you do, donât expect a particularly meaningful outcome
youâve got a class.
what would you like to do with it?
usually what youâd do with a class is to create an instance of it. for example:
an_empty_list = list()
calling a class results in an instance of it.
lists_class = list
so now youâve got two values, list()
and list
⌠those are really different things.
you could ask for attributes from them
list().something
list.something
what attribute does a list have? what attributes does the list class have?
what makes sense to do with the list classâs append attribute, and what about a list instanceâs append attribute?
if you call a listâs append attribute whatâll happen is that the value you provide is added to that list
but if you do the same with the list class, then what list would this add to? it wouldnât, thereâs no list, only the idea of list, a type