[Python-ideas] Why does += trigger UnboundLocalError?

Nick Coghlan ncoghlan at gmail.com
Wed Jun 1 14:43:07 CEST 2011

On Wed, Jun 1, 2011 at 2:52 PM, Carl M. Johnson
<cmjohnson.mailinglist at gmail.com> wrote:
> We all know that the following code won't work because of UnboundLocalError
> and that to get around it, one needs to use nonlocal:

There's no fundamental reason this couldn't change, but actually
changing it simply isn't worth the hassle, so the status quo wins the

I elaborated further on this point when the topic came up last year:


Nick Coghlan   |   ncoghlan at gmail.com   |   Brisbane, Australia

More information about the Python-ideas mailing list