我的目标是解析一个类并返回一个描述该类中包含的方法和相关参数的数据结构(对象、字典等)。如果能包括类型和返回值信息则更佳。要求使用Python实现。
例如,下面的类:
class Foo:
def bar(hello=None):
return hello
def baz(world=None):
return baz
将被解析并返回
result = {class:"Foo",
methods: [{name: "bar", params:["hello"]},
{name: "baz", params:["world"]}]}
那只是我想法的一个例子...在数据结构方面,我非常灵活。
有什么想法/示例可以实现这个吗?