#! /usr/bin/env python
# -*- coding: utf-8 -*-

#==========================================
# apihelper1: módulo adaptado de apihelper (inmersión en pyton)
#                   devuelve una lista con la información pedida
#------------------------------------------------------------------------------------
# FJA - neocipres@telefonica.net, Octubre de 2006
#==========================================
 
def help(object, spacing=10, collapse=1, imprime=1):
    """Print methods and doc strings.
    
    Takes module, class, list, dictionary, or string."""
    methodList = [method for method in dir(object) if callable(getattr(object, method))]
    processFunc = collapse and (lambda s: " ".join(s.split())) or (lambda s: s)
    salida = []
    for method in methodList:
        bloque = "=> ".join(["%s %s \n-------------------------------------------------------------------------"
                                %  (method.ljust(spacing),  processFunc(str(getattr(object, method).__doc__)))])
            
        if imprime:
            print bloque
            bloque = ""
        else:
            salida.append(str(bloque+"\n"))
    return salida    

if __name__ == "__main__":                
    print help.__doc__
