11. Building Useful Classes


#1

Hi all,

I have tried some of the possible solutions mentioned in the help threads, but nothing seems to work.


The error message is as follows:
Oops, try again. Make sure you define your own repr() for the Point3D class.

Please look at the code below:

class Point3D(object):
    def __init__(self,x,y,z):
        self.x=x
        self.y=y
        self.z=z

    def __rep__(self):
        return ("(%d, %d, %d)") % (self.x,self.y,self.z)
    
my_point=Point3D(1,2,3)

print my_point

Thanks in advance


11/11 building useful classes
#2

Never mind all.

Found the mistake : It should be repr and not rep


#3

This topic was automatically closed 7 days after the last reply. New replies are no longer allowed.