Is this a bug?

Zachary Ware zachary.ware+pylist at gmail.com
Mon Jul 15 12:06:09 EDT 2013


On Mon, Jul 15, 2013 at 10:50 AM, Jack Bates <tdhfwh at nottheoilrig.com> wrote:
> Hello,
>
> Is the following code supposed to be an UnboundLocalError?
> Currently it assigns the value 'bar' to the attribute baz.foo
>
>    foo = 'bar'
>    class baz:
>       foo = foo

No bug.  It's not an error because of differences in the way classes
and functions compile.

--
Zach



More information about the Python-list mailing list