Magic function

Paul Rubin http
Fri Jan 11 21:54:09 CET 2008


dg.google.groups at thesamovar.net writes:

> obj1 = Obj(params1)
> obj2 = Obj(params2)
> ...
> run()
> 
> The idea is that the run() function inspects the stack, and looks for
> object which are instances of class Obj, creates a Bigobj with those
> objects and calls its run() method.
> 
> So, any comments on that approach?

Bleeearrrrrggggh!!!!  Just make the object initializer remember where
the instances are.  Or, write something like:
    
    newobj = Bigobj() 
    # give Bigobj a __call__ method to create and record an object

    obj1 = newobj(params1)  
    obj2 = newobj(params2)
    ...
    newobj.run()



More information about the Python-list mailing list