The objects are correct - and new objects - their repr
however is wrong:
int he __repr__
method of Tunnel you are printing the "x" and "y" variables, not the
self.x
and self.y
attributes of the object.
The way your code is right now:
def __repr__ (self):
return "%s %s" % (str(x),str(y))
makes Python search for the global x and y variables - which happen to exist, and correspond to the values used to create the latest object.
Also - if you are using Python 2.x, make sure any classes you create inherit from object
-
otherwise you can find unexpected behavior ahead.