Gert Cuykens wrote: > def obj(): > return {'data':'hello', > 'add':add(v)} > > def add(v): > data=data+v > > if __name__ == '__main__': > test=obj() > test.add('world') > print test.data > > I don't know why but i have one of does none class c programing style > moods again. I was wondering if the following was possible without > using a class ?
def obj(): result = {'data': 'hello'} result['add'] = adder(result) return result def adder(obj): def add(value): obj['data'] += value return add if __name__ == '__main__': test = obj() test['add']('world') print test['data'] -- http://mail.python.org/mailman/listinfo/python-list