python - Referencing a property of an object from an another object -
a little stuck on code wondering if me out.
this part of code has been acting up:
def computerchoice(): wvar2 = 0 aseat in seats: aseat1 = aseat while wvar2 < int(noofseats): print(aseat1) if aseat1.rightobject == "_": break elif aseat1.rightobject.booked == false: aseat1 = aseat1.rightobject wvar2 += 1 else: break possibleseats.append(aseat.co)
where rightobject references object same class. comes error message:
attributeerror: 'int' object has no attribute 'booked'
with couple of print statements figured out while loop works first time. when aseat1 being reassigned , when property of called turns 0.
e.g. can't
aseat1.rightobject.rightobject.booked
does know how fix or have go @ angle?
edit: initialisation of class follows:
class seat: def __init__ (self,seat_coordinate,seat_booked,seat_right,seat_right_object,seat_worth): self.co = seat_coordinate self.booked = seat_booked self.right = seat_right self.rightobject = seat_right_object self.worth = seat_worth
with example object being:
a1 = seat("a1", false, "a2", a2, "a2", 0)
thanks responses far
Comments
Post a Comment