+ 1

Why the below code is printing object address instead of object content?

IDE: i am using pycharm to run the below code. Ver: Python 3.7 and above Code Snippet: class Point: def __init__(self, x =1 ,y =1 , z=1): self.x=x self.y=y self.z=z def ___str___(self): return f'x: {self.x} , y: {self.y}, z:{self.z}' p1 = Point(4,2,9) def f1(): print(p1) f1() Expected: x: 4, y:2, z:9

27th Aug 2019, 2:51 PM
Anil Patil
Anil Patil - avatar
2 ответов
+ 1
Try this: https://code.sololearn.com/cWV8UNcj43Xh/#py You called to print the Address, but didn't called the ___str___() function. Ask for more details.
30th Apr 2020, 3:38 PM
Ratul Hasan🇧🇩
Ratul Hasan🇧🇩 - avatar
0
its __str__ not ___str___
1st May 2020, 2:46 PM
Sousou
Sousou - avatar