Is this a bug, or is it me?

Hrvoje Niksic hniksic at xemacs.org
Thu Jan 17 10:45:01 EST 2008


cptnwillard at gmail.com writes:

> Hello all,
> For some reason, the following does not work :
>
>
> class C:
>     TYPES = [None]
>     DICT = {}
>     for Type in TYPES:
>         DICT.update((E,Type) for E in [1])
>
>>>> NameError: global name 'Type' is not defined
>
>
> What do you think? Is this a bug?

It works if you change the generator expression to a list
comprehension, by adding [] around it.  Feels like a bug to me, but
there might be subtleties involved.



More information about the Python-list mailing list