Merge pull request #612 from tjwei/master

fix a set comprehension issue
This commit is contained in:
Dave Halter
2015-08-09 12:18:10 +02:00
2 changed files with 18 additions and 1 deletions

View File

@@ -242,7 +242,7 @@ class Evaluator(object):
except (IndexError, AttributeError):
pass
else:
if isinstance(comp_for, tree.CompFor):
if isinstance(comp_for, tree.CompFor) and c[0] != '{':
return [iterable.Comprehension.from_atom(self, atom)]
return [iterable.Array(self, atom)]

View File

@@ -50,6 +50,23 @@ left
##? str()
{a-1:b for a,b in {1:'a', 3:1.0}.items()}[0]
# with a set literal
#? int()
[a for a in {1, 2, 3}][0]
#? set()
{a for a in range(10)}
##? int()
[x for x in {a for a in range(10)}][0]
##? int()
{a for a in range(10)}.pop()
##? int()
iter({a for a in range(10)}).next()
# list comprehensions should also work in combination with functions
def listen(arg):
for x in arg: