Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- import ast
- from macropy.core.macros import *
- macros = Macros()
- @macros.expr
- def od(tree, **kw):
- pair = ast.Tuple(elts=[tree.key, tree.value])
- gx = ast.GeneratorExp(elt=pair, generators=tree.generators)
- odict = ast.Attribute(value=ast.Name(id='collections'),
- attr='OrderedDict')
- call = ast.Call(func=odict, args=[gx], keywords=[])
- return call
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement