brython-dev / brython

Brython (Browser Python) is an implementation of Python 3 running in the browser
BSD 3-Clause "New" or "Revised" License
6.39k stars 510 forks source link

Issues with default arguments #1632

Closed pamelafox closed 3 years ago

pamelafox commented 3 years ago

The following code produces a NameError on Brython, but works fine in Python 3.

def add_seen_k(k, f=lambda x: 0):
    def inner(z):
        print(k)
        return k
    return inner

a = add_seen_k(3)
a(3)

It works correctly without the default arguments, so presumably there's an issue with the parsing of default arguments?

pamelafox commented 3 years ago

Thank you so much! This will mean we can do assignments with default arguments in our class.