def _define(self, obj):
        if inspect.isclass(obj):
            bases = inspect.getmro(obj)
            bases = [ x.__name__ for x in bases[1:] ]
            if bases:
                bases = ' -- Bases (' + ', '.join(bases) + ')'
            else:
                bases = '' 
            if hasattr(obj, '__init__') and inspect.isroutine(obj.__init__):
                try:
                    initfn = obj.__init__.im_func
                    argspec = inspect.getargspec(initfn)
                    # get rid of self from arg list...
                    fnargs = argspec[0][1:] 
                    newArgSpec = (fnargs, argspec[1], argspec[2], argspec[3])
                    argspec = inspect.formatargspec(*newArgSpec)
                except TypeError:
                    argspec = '(?)'
            else:
                argspec = ''
            print "Class " + obj.__name__ + argspec + bases
        elif inspect.ismethod(obj) or type(obj).__name__ == 'method-wrapper':
            m_class = obj.im_class
            m_self = obj.im_self
            m_func = obj.im_func
            name = m_class.__name__ + '.' +  m_func.__name__
            #if m_self:
            #    name = "<Bound>"  + name
            argspec = inspect.formatargspec(*inspect.getargspec(m_func))
            print (name, argspec) % "%s%s"
        elif type(obj).__name__ == 'builtin_function_or_method':
            print obj
        elif inspect.isfunction(obj):
            name = obj.__name__
            argspec = inspect.formatargspec(*inspect.getargspec(obj))
            print "%s%s" % (name, argspec)
        else:
            print type(obj)
dataset/ETHPy150Open sassoftware/conary/conary/lib/epdb_embedded/__init__.py/Epdb._define/swapped operands of `%`