[Python-Dev] fuzzy logic?
Michael Hudson
mwh21@cam.ac.uk
14 Dec 2000 13:58:24 +0000
1) Is there anything is the standard library that does the equivalent
of
import symbol,token
def decode_ast(ast):
if token.ISTERMINAL(ast[0]):
return (token.tok_name[ast[0]], ast[1])
else:
return (symbol.sym_name[ast[0]],)+tuple(map(decode_ast,ast[1:]))
so that, eg:
>>> pprint.pprint(decode.decode_ast(parser.expr("0").totuple()))
('eval_input',
('testlist',
('test',
('and_test',
('not_test',
('comparison',
('expr',
('xor_expr',
('and_expr',
('shift_expr',
('arith_expr',
('term',
('factor', ('power', ('atom', ('NUMBER', '0'))))))))))))))),
('NEWLINE', ''),
('ENDMARKER', ''))
? Should there be? (Especially if it was a bit better written).
... and Greg's just said everything else I wanted to!
Cheers,
M.
--
please realize that the Common Lisp community is more than 40
years old. collectively, the community has already been where
every clueless newbie will be going for the next three years.
so relax, please. -- Erik Naggum, comp.lang.lisp