I am generating list of class variables as below and i need print the value of those variable.
class MYClass(object):
a = '1'
b = '20'
c = 'hello'
def as_list(self):
return [attr for attr in dir(MYClass()) if not callable(attr) and not attr.startswith("__") and not attr == 'as_list']
c = MYClass()
print c.as_list()
The above code would result in ['a', 'b', 'c'] but i need the value as ['1', '20', 'hello']
dir(self)instead ofdir(MYClass())be more appropriate?