updating local()

Robert Kern robert.kern at gmail.com
Thu Oct 6 10:15:12 EDT 2005


Flavio wrote:
> Ok, its not thousands, but more like dozens of variables...
> I am reading a large form from the web which returns a lot of values.
> (I am Using cherrypy)
> 
> I know I could pass these variables around as:
> 
> def some_function(**variables):
>     ...
> 
> some_function(**variables)
> 
> but its a pain in the neck to have to refer to them as
> variables['whatever']...
> 
> dont you think? 

Use a Bunch.

class Bunch(dict):
    def __init__(self, *args, **kwds):
        dict.__init__(self, *args, **kwds)
        self.__dict__ = self

-- 
Robert Kern
rkern at ucsd.edu

"In the fields of hell where the grass grows high
 Are the graves of dreams allowed to die."
  -- Richard Harter




More information about the Python-list mailing list