mirror of
https://github.com/python/cpython.git
synced 2025-08-04 00:48:58 +00:00
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:
parent
2528b19a86
commit
578ceee042
2 changed files with 7 additions and 0 deletions
|
@ -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!"
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue