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 scope issue with parameter or local variable #36

Closed GoogleCodeExporter closed 9 years ago

GoogleCodeExporter commented 9 years ago
Code:
def instance(i):
    o = object()
    o.id = i
    return o

def f(o):
    x = [ o.id for i in range(1) ]
    print(x)

o = instance(999)
f( instance(1) )

Result in:
[ 999 ]

Instead of:
[ 1 ]

This definition does not change the output:
def f(o):
    o = instance(2)
    x = [ o.id for i in range(1) ]
    print(x)

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

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

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