printing the instance in Python
Posted
by kame
on Stack Overflow
See other posts from Stack Overflow
or by kame
Published on 2010-04-21T12:24:24Z
Indexed on
2010/04/21
12:33 UTC
Read the original article
Hit count: 180
Hello! With this code:
class Complex:
def __init__(self, realpart, imagpart):
self.real = realpart
self.imag = imagpart
print self.real, self.imag
class Circle:
def __init__(self, radius):
print "A circle wiht the radius", radius, "has the properties:"
print "circumference =", 3.14*radius
print "area =", 3.14*radius**2
I get this output:
>>> Complex(3,2)
3 2
<__main__.Complex instance at 0x01412210>
But why does he print the last line?
© Stack Overflow or respective owner