11 building useful classes


Traceback (most recent call last):
File "python", line 11, in
File "python", line 8, in repr
AttributeError: 'Point3D' object has no attribute 'z'

Stuck! Any suggestions?

Replace this line with your code. 
class Point3D(object):
    def __init__(self, x, y, z):
        self.x = x
        self.y = y
        self.x = x
    def __repr__(self):
        return "(%d, %d, %d)" % (str(self.x, self.y, self.z)) 
my_point = Point3D(1, 2, 3)     
print my_point


Change the second line like this to, self.z = z.


mtf Thank you!I I must have been staring at the screen for too long to miss it!


When I hit a wall, I stop for 15 minutes and do a couple of Sudoku puzzles. It helps remove the blockers.


Yes, good idea. They say the mind can only absorb information in 50 minute increments, max. Hence, 50 min counseling sessions, concert sets, etc. Then it needs a break. Thanks for your help.


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