In some classes, doing str(class) will give you a string, such as 'something'. However, whenever I make a class, it only ever gives <__main__.Test object at 0x0000026FB34D70B8>.
How do I make it return a string, such as '0', or even '100'?
In some classes, doing str(class) will give you a string, such as 'something'. However, whenever I make a class, it only ever gives <__main__.Test object at 0x0000026FB34D70B8>.
How do I make it return a string, such as '0', or even '100'?
 
    
     
    
    Short answer: by overloading the class' __str__ and/or __repr__ methods, depending on what you need.
class Frobber:
    ...
    def __str__ ( self ):
        return "<Frobber {}>".format(self.someVariable)
