python ast


import ast

print ast.literal_eval('[1, 2, 3]')
print eval("2 + 3 * len('hello')") == 17
print eval("__import__('os').system('dir')", {})

s = """
(lambda fc=(
lambda n: [
c for c in
().__class__.__bases__[0].__subclasses__()
if c.__name__ == n
][0]
):
fc("function")(
fc("code")(
0,0,0,0,"KABOOM",(),(),(),"","",0,""
),{}
)()
)()
"""
#print eval(s, {'__builtins__':{}})

print ().__class__.__bases__[0]
print type(().__class__.__bases__[0].__subclasses__())

for i in ().__class__.__bases__[0].__subclasses__():
print '\n'
print i

for i in ().__class__.__bases__:
print "*****************\n"
print i
print '\n\n\n'
ALL_CLASSES = ().__class__.__bases__[0].__subclasses__()
#print [c for c in ALL_CLASSES if c.__name__ == n][0]
g = lambda x: x*2

print g(3)

#[c for c in ALL_CLASSES if c.__name__ == "operator.attrgetter" ][0]
#[c for c in ALL_CLASSES if c.__name__ == "operator.attrgetter" ][0]

#ff = lambda n: [c for c in ALL_CLASSES ][0]
#a = ff("function")

print [c for c in ALL_CLASSES][0]

posted on 2016-09-27 16:21  与非朋仔  阅读(704)  评论(0编辑  收藏  举报

导航