All,
A class:
class foo():
def __init__(self):
self.avar1 = 0
self.bvar2 = 1
self.cvar3 = 3
def debug_info(self):
print "avar1:" avar1
print "bvar2:" bvar2
print "cvar3:" cvar3
my question, it is too complex to write the debug_info() if I got a lot of self.vars ,then I want to migrate them into a dict to print them in one go for debug and monitor purpose, however, maybe I do not want to lost the format
foo.avar1 = 0
to access the vars inside of the class, because it is easy to read and easy to use and modify. Do you have better idea instead of visit the class.dict for the debug_info output? or does someone knows a better way to make this class more simple?
Thanks!
def debug_info ( self ):
for ( key, value ) in self.__dict__.items():
print( key, '=', value )
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With