0

Why is the "spam" variable recognized as the self contend and the "hello" variable as the other content?

My Question is, how does it identify which variable ("spam" and "hello" in this example) is the self and which the other content? Where does it say which is which? And why are not both identified as self, since both are in the Special String class. This is the code from the python course, Module "Object-Orienting Programming", Section 3/8 "Magic Methods & Operator Overloading. class SpecialString: def __init__(self, cont): self.cont = cont def __truediv__(self, other): line = "=" * len(other.cont) return "\n".join([self.cont, line, other.cont]) spam = SpecialString("spam") hello = SpecialString("Hello world!") print(spam / hello) Thanks for answers :)

22nd Feb 2018, 4:59 PM
Ben K
1 Answer
+ 3
The First one is the self and the secon the other. self / other
23rd Feb 2018, 12:59 PM
Ninj4