On Jan 17, 2008 10:05 AM,  <[EMAIL PROTECTED]> wrote:
> 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?

You cannot access a class's class variables in it's class-statement
scope, since the name of the type is not bound until after the class
statement is completed.

Try:

class C:
  TYPES = [None]
  DICT = {}

for Type in C.TYPES:
  C.DICT.update((E, Type) for E in [1])

-- 
Neil Cerutti <[EMAIL PROTECTED]>
-- 
http://mail.python.org/mailman/listinfo/python-list

Reply via email to