From 099ad28ad1dbe05822b3b917b8bd4259e4961865 Mon Sep 17 00:00:00 2001 From: Guillermo Vaya Date: Wed, 17 Jul 2013 15:40:38 +0200 Subject: [PATCH] added @paultag suggestions --- hy/compiler.py | 10 +++------- 1 file changed, 3 insertions(+), 7 deletions(-) diff --git a/hy/compiler.py b/hy/compiler.py index c613b70..9b3be30 100644 --- a/hy/compiler.py +++ b/hy/compiler.py @@ -1144,13 +1144,9 @@ class HyASTCompiler(object): # (assoc foo bar baz) => foo[bar] = baz target = self.compile(expr.pop(0)) ret = target - while expr: - key = self.compile(expr.pop(0)) - try: - val = self.compile(expr.pop(0)) - except IndexError: - raise HyCompileError( - "Key {key} has no value to associate".format(key)) + i = iter(expr) + for (key, val) in ((self.compile(x), self.compile(y)) + for (x, y) in zip(i, i)): ret += key + val + ast.Assign( lineno=expr.start_line,