Advertisement
Guest User

Untitled

a guest
Jan 13th, 2014
715
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 0.39 KB | None | 0 0
  1. import ast
  2. from macropy.core.macros import *
  3.  
  4. macros = Macros()
  5.  
  6. @macros.expr
  7. def od(tree, **kw):
  8.     pair = ast.Tuple(elts=[tree.key, tree.value])
  9.     gx = ast.GeneratorExp(elt=pair, generators=tree.generators)
  10.     odict = ast.Attribute(value=ast.Name(id='collections'),
  11.                           attr='OrderedDict')
  12.     call = ast.Call(func=odict, args=[gx], keywords=[])
  13.     return call
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement