Question on statically nested scopes

holger krekel pyth at
Thu Aug 29 21:30:59 CEST 2002

Manus Hand wrote:
> In my code, I use a very handy trick:
> class Whatever:
>     def someFunction(self, **params):
>         vars().update(locals())
> This means that whatever named variables I pass into "someFunction"
> become attributes of the object (accessible with self.varName, etc.).

What do you think PEP227 (statically nested scopes) has to do 
with this whole issue?

And you probably meant 'vars(self).update(params)'.

But anyway, you could do

    def someFunction(self, **params):
        for key,value in params:
            setattr(self, key, value)

    def someFunction(self, **params):

and don't have to worry much :-)



More information about the Python-list mailing list