I have a situation like this:
import xml.etree.cElementTree as etree
class Universe(object):
def get_node(self, label, attribs):
return etree.Element(
type(label), label=label, **attribs)
class Planet(Universe):
def __init__(self, name, nom=0):
super(Planet, self).__init__()
self._name = name
self._nom = nom
def label(self):
return self._name
def no_of_moons(self):
return self._nom
class Earth(object):
def __init__(self):
self.life_support = True
self.presence_of_water = True
planet_earth = Planet(self, nom=1)
self.node = planet_earth.get_node(self, self.__dict__)
earth = Earth()
print earth.node
so I get output of earth like this <Element <class 'Earth'> at 0x108fa1ed0>
but instead I want output like: <Element Earth(life_support=True, nom=True)>
now I know I can override __repr__
to result something like above, but etree.Element
is a function of the type 'builtin_function_or_method
and I don't know how can output that can something be useful for debugging.