Hi, I am wondering a good way to follow if i would like to redefine the members of a previous defined class in ipython. say : I have defined a class intro like below, and later i want to redefine part of the function definition _print_api. Any way to do that without retyping it .
class intro(object):
def _print_api(self,obj):
def _print(key):
if key.startswith('_'):
return ''
value = getattr(obj,key)
if not hasattr(value,im_func):
doc = type(valuee).__name__
else:
if value.__doc__ is None:
doc = 'no docstring'
else:
doc = value.__doc__
return ' %s :%s' %(key,doc)
res = [_print(element) for element in dir(obj)]
return '\n'.join([element for element in res if element != ''])
def __get__(self,instance,klass):
if instance is not None:
return self._print(instance)
else:
return self._print_api(klass)