Add simple test of list comprehension that uses a name that isn't

otherwise used in the same code block.  (Not sure this is the right
place, but there is no test_list_comprehensions.py.)
This commit is contained in:
Jeremy Hylton 2001-01-23 01:51:40 +00:00
parent 2528b19a86
commit 578ceee042
2 changed files with 7 additions and 0 deletions

View file

@ -612,6 +612,12 @@ print [3 * x for x in nums]
print [x for x in nums if x > 2]
print [(i, s) for i in nums for s in strs]
print [(i, s) for i in nums for s in [f for f in strs if "n" in f]]
def test_in_func(l):
return [None < x < 3 for x in l if x > 2]
print test_in_func(nums)
try:
eval("[i, s for i in nums for s in strs]")
print "FAIL: should have raised a SyntaxError!"