object oriented programming #python #output | Sololearn: Learn to code for FREE!
New course! Every coder should learn Generative AI!
Try a free lesson
+ 1

object oriented programming #python #output

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) Result: >>> spam ============ Hello world! >>>

7th Apr 2018, 5:16 PM
Smriti Rastogi
Smriti Rastogi - avatar
3 Answers
+ 4
Is this a question?
8th Apr 2018, 3:45 AM
Yash✳️
Yash✳️ - avatar
+ 1
truediv is a magic method which will be called on division (/) operation resulting in that output
9th Apr 2018, 2:09 PM
kaliki chandu
kaliki chandu - avatar
0
how the output has come....?? the control flow of the python program...?? the "__truediv__(self,other)" is not called once....how the output is generated.??
9th Apr 2018, 1:55 PM
Smriti Rastogi
Smriti Rastogi - avatar