How to alter print behavior for an object in python -


i have unique class created , wish control output of flow..e.g:

obj = myobject() print obj 

so instead of python does, want alter output. how do such thing?

change __str__ method

class myobject(object):     def __str__(self):         return 'foo'   >>> print myobject() foo 

Comments

Popular posts from this blog

SPSS keyboard combination alters encoding -

Socket.connect doesn't throw exception in Android -

iphone - How do I keep MDScrollView from truncating my row headers and making my cells look bad? -