I'm practicing for a midterm, and I came across this:
the_cake = [1,2,[3],4,5]
a_lie = the_cake[1:4]
the_cake = the_cake[1:4]
great = a_lie
delicious = the_cake
moist = great[:-1]
After running this code in the Python interpreter, why is:
the_cake.append == a_lie.append
False
My thought is that they are equal methods, and though not "IS", should fulfill the equality.
Maybe this evaluates to False because of instantiation? If this is true, then do class attributes evaluate to True when compared? Is this a special case with list objects?
Follow-up: According to this: Is there a difference between `==` and `is` in Python?
"IS will return True if two variables point to the same object, == if the objects referred to by the variables are equal."
Then do methods of the List class point to separate instances of the "append" method?
So if I define a function x(parameter), every time I call it, it'll be the same because it's the same object assigned to different variables, right?
Then for some equivalent variable "parameter":
x(parameter) == x(parameter)
True
Thanks!