def export_true_table():
    """Export value, checker function output true table.
    Help to organize thought.
    
    klass.__dict__ 指的是在类定义中定义的, 从父类继承而来的不在此中。
    """
    tester_list = [
        ("inspect.isroutine", lambda v: inspect.isroutine(v)),
        ("inspect.isfunction", lambda v: inspect.isfunction(v)),
        ("inspect.ismethod", lambda v: inspect.ismethod(v)),
        ("isinstance.property", lambda v: isinstance(v, property)),
        ("isinstance.staticmethod", lambda v: isinstance(v, staticmethod)),
        ("isinstance.classmethod", lambda v: isinstance(v, classmethod)),
    ]

    class_attr_value_paris = [
        ("attribute", MyClass.attribute),
        ("property_method", MyClass.property_method),
        ("regular_method", MyClass.regular_method),
        ("static_method", MyClass.static_method),
        ("class_method", MyClass.class_method),
        ("__dict__['static_method']", Base.__dict__["static_method"]),
        ("__dict__['class_method']", Base.__dict__["class_method"]),
    ]

    myclass = MyClass()
    instance_attr_value_paris = [
        ("attribute", myclass.attribute),
        ("property_method", myclass.property_method),
        ("regular_method", myclass.regular_method),
        ("static_method", myclass.static_method),
        ("class_method", MyClass.class_method),
        #         ("__dict__['static_method']", myclass.__dict__["static_method"]),
        #         ("__dict__['class_method']", myclass.__dict__["class_method"]),
    ]

    print(inspect.getargspec(MyClass.regular_method))
    print(inspect.getargspec(MyClass.static_method))
    print(inspect.getargspec(MyClass.class_method))

    print(inspect.getargspec(myclass.regular_method))
    print(inspect.getargspec(myclass.static_method))
    print(inspect.getargspec(myclass.class_method))

    # index是方法名, column是属性名
    def create_true_table_dataframe(index_tester, column_attr):
        df = pd.DataFrame()
        for attr, value in column_attr:
            col = list()
            for name, tester in index_tester:
                try:
                    if tester(value):
                        flag = 1
                    else:
                        flag = 0
                except:
                    flag = -99
                col.append(flag)
            df[attr] = col
        df.index = [name for name, _ in index_tester]
        return df

    version = "%s.%s" % (sys.version_info.major, sys.version_info.minor)

    df = create_true_table_dataframe(tester_list, class_attr_value_paris)
    df.to_csv("%s_class.csv" % version, index=True)

    df = create_true_table_dataframe(tester_list, instance_attr_value_paris)
    df.to_csv("%s_instance.csv" % version, index=True)
def export_true_table ( ) : tester_list = [ ( "inspect.isroutine" , lambda v : inspect . isroutine ( v ) ) , ( "inspect.isfunction" , lambda v : inspect . isfunction ( v ) ) , ( "inspect.ismethod" , lambda v : inspect . ismethod ( v ) ) , ( "isinstance.property" , lambda v : isinstance ( v , property ) ) , ( "isinstance.staticmethod" , lambda v : isinstance ( v , staticmethod ) ) , ( "isinstance.classmethod" , lambda v : isinstance ( v , classmethod ) ) , ] class_attr_value_paris = [ ( "attribute" , MyClass . attribute ) , ( "property_method" , MyClass . property_method ) , ( "regular_method" , MyClass . regular_method ) , ( "static_method" , MyClass . static_method ) , ( "class_method" , MyClass . class_method ) , ( "__dict__['static_method']" , Base . __dict__ [ "static_method" ] ) , ( "__dict__['class_method']" , Base . __dict__ [ "class_method" ] ) , ] myclass = MyClass ( ) instance_attr_value_paris = [ ( "attribute" , myclass . attribute ) , ( "property_method" , myclass . property_method ) , ( "regular_method" , myclass . regular_method ) , ( "static_method" , myclass . static_method ) , ( "class_method" , MyClass . class_method ) , ] print ( inspect . getargspec ( MyClass . regular_method ) ) print ( inspect . getargspec ( MyClass . static_method ) ) print ( inspect . getargspec ( MyClass . class_method ) ) print ( inspect . getargspec ( myclass . regular_method ) ) print ( inspect . getargspec ( myclass . static_method ) ) print ( inspect . getargspec ( myclass . class_method ) ) def create_true_table_dataframe ( index_tester , column_attr ) : df = pd . DataFrame ( ) for attr , value in column_attr : col = list ( ) for name , tester in index_tester : try : if tester ( value ) : flag = 1 else : flag = 0 except : flag = - 99 col . append ( flag ) df [ attr ] = col df . index = [ name for name , _ in index_tester ] return df version = "%s.%s" % ( sys . version_info . major , sys . version_info . minor ) df = create_true_table_dataframe ( tester_list , class_attr_value_paris ) df . to_csv ( "%s_class.csv" % version , index = True ) df = create_true_table_dataframe ( tester_list , instance_attr_value_paris ) df . to_csv ( "%s_instance.csv" % version , index = True )
Export value, checker function output true table.
    Help to organize thought.
    
    klass.__dict__ 指的是在类定义中定义的, 从父类继承而来的不在此中。