string - call __str__ inside a class? python 3.X -
im trying develop elevator simulator. when lift move floor , want able display how many customers waiting , in lift, floor ect. (one string)
when call self.__str__()
inside while loop , goes in doesn't return string screen.
can give out bit thanks
you should not calling __str__
directly. should called str(object) or let automatically convert.
also returns readable string representing object. not print it. want do.
print(self.__str__())
or just
print(self)
Comments
Post a Comment