I want to define a class with it's __repr__
method defined in such a way that it will write out only the names and values of all attributes that are not methods. How can I do this? I have managed to write it like this, but I realize that this does not check for the attribute type.
class Example:
def __repr__(self):
return "\n".join(["%s: %s" % (x, getattr(self, x)) for x in dir(self) if not x.startswith('__')])
What is missing here is the check for the type of the attribute.