Re: dynamically inserting function into an object

2005-01-13 Thread hanz
# class Cell(object): # def __init__(self, initialvalue = 0): #self._func = lambda x: x #self.__value = initialvalue # # def setvalue (self, newvalue): # self.__value = self._func(newvalue) # # def getvalue (self): # return self.__value # # def delval

Re: lambda

2005-01-13 Thread hanz
Antoon Pardon wrote: > So if I have a call with an expression that takes more than > one line, I should assign the expression to a variable and > use the variable in the call? Yes, that's sometimes a good practice and can clarify the call. > But wait if I do that, people will tell me how bad tha

Re: dict.updated

2005-01-12 Thread hanz
Rick Morrison wrote: > >>> [updated(d, {'c':3}) for d in [{'a':1, 'b':2}, {'x':10, 'y':'11'}]] > [{'a': 1, 'c': 3, 'b': 2}, {'y': '11', 'x': 10, 'c': 3}] I don't really understand the use of this. Can you give a less toy example? I'd probably just do dicts = [{'a':1, 'b':2}, {'x':10, 'y':'11'}]