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

Popular posts from this blog

node.js - Mongoose: Cast to ObjectId failed for value on newly created object after setting the value -

gradle error "Cannot convert the provided notation to a File or URI" -

[C++][SFML 2.2] Strange Performance Issues - Moving Mouse Lowers CPU Usage -