views:

36

answers:

0

Suppose I am building a composite set of types:

def subordinate_type(params):
   #Dink with stuff
   a = type(myname, (), dict_of_fields)
   return a()

def toplevel(params)
    lots_of_types = dict(keys, values)
    myawesomedynamictype = type(toplevelname, (), lots_of_types)

    #Now I want to edit some of the values in myawesomedynamictype's 
    #lots_of_types. 

    return myawesomedynamictype()

In this particular case, I want a reference to the "typeclass" myawesomedynamictype inserted into lots_of_types.

I've tried to iterate through lots_of_types and set it, supposing that the references were pointed at the same thing, but I found that the myawesomedynamictype got corrupted and lost its fields.

The problem I'm trying to solve is that I get values related to the type subordinate_type, and I need to generate a toplevel instantiation based on subordinate_type.