sgzwiz / brython

Automatically exported from code.google.com/p/brython
BSD 3-Clause "New" or "Revised" License
0 stars 1 forks source link

List comprehension fails with conditions (locally defined function lookup issue) #35

Closed GoogleCodeExporter closed 9 years ago

GoogleCodeExporter commented 9 years ago
Following code works:

def f(n):
    ln = range(n)

    def condx(i):
        return i % 2 == 0

    return condx(n)

f(10)

Following variation does not:
def f(n):
    ln = range(n)

    def condx(i):
        return i % 2 == 0

    return [ i for i in ln if condx(i) ]

f(10)

=> ReferenceError: condx is not defined

Original issue reported on code.google.com by pedro.ro...@gmail.com on 5 Jan 2013 at 1:51

GoogleCodeExporter commented 9 years ago
Fixed in rev #340 : list of names/values to pass to $list_comp was not complete

Original comment by pierre.q...@gmail.com on 6 Jan 2013 at 8:09