11 building useful classes


#1





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


#2

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


#3

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


#4

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


#5

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.


#6

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