I'm trying to make an array of class objects. When I create the object, it works great:
class Complex(object):
def __init__(self, realpart, imagpart):
#creates complex number
self.r = realpart
self.i = imagpart
def __str__(self):
'''Returns complex number as a string'''
return '(%s + %s j)' % (self.r, self.i)
a = Complex(1,0)
print a
(1 + 0 j)
But when I try to put a in an array, I get an error:
arr1 = [a]
[<__ main __.Complex object at 0x5afab0>]
Why could this be happening? Thanks in advance.