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 -

Add new record to the table by click on the button in Microsoft Access -

javascript - jQuery .height() return 0 when visible but non-0 when hidden -