- Python sees you mentioned mystuff and looks up that variable. It might have to look backward
to see if you created it with =, if it is a function argument, or if it’s a global variable. Either way
it has to find the mystuff first.
- Once it finds mystuff it reads the . (period) operator and starts to look at variables that are a
part of mystuff. Since mystuff is a list, it knows that mystuff has a bunch of functions.
- It then hits append and compares the name to all the names that mystuff says it owns. If append
is in there (it is), then Python grabs that to use.
- Next Python sees the ( (parenthesis) and realizes, ”Oh hey, this should be a function.” At this
point it calls (runs, executes) the function just like normally, but instead it calls the function with
an extra argument.
- That extra argument is … mystuff! I know, weird, right? But that’s how Python works, so it’s
best to just remember it and assume that’s the result. What happens, at the end of all this, is
a function call that looks like: append(mystuff, ‘hello’) instead of what you read, which is
Here’s what I don’t understand:
2.) Is the variables part of mystuff the items in it?
3.) Why when it hits append, it compares to all the names that mystuff says it owns instead of carrying out the append function. Moreover, is the things that mystuff owns, the items inside the list?
4.) What does it mean by “calls the function with an extra argument”
5.) Isn’t mystuff what it read in the first place/looked up? Then what happens to the string ‘hello’? And finally, why is mystuff.append(‘hello’) now append(mystuff, ‘hello’), I thought that mystuff was read first?