Bo Peng wrote:

My function and dictionaries are a lot more complicated than these so I would like to set dict as the default namespace of fun.

This sounds to me like you're trying to re-implement object orientation.

Turn all of those functions into methods on a class, and instead of creating dictionaries that'll be passed into functions, create class instances.

class MyClass(object):
    def __init__(self, **kwargs):
        for key, val in kwargs:
            setattr(self, key, val)
    def fun(self):
        self.z = self.y + self.x

a = MyClass(x=1, y=2)
a.fun()
print a.z

Jeff Shannon
Technician/Programmer
Credit International


-- http://mail.python.org/mailman/listinfo/python-list

Reply via email to