[Tutor] modified dictionary class

Alan Gauld alan.gauld at btinternet.com
Mon Dec 6 14:44:08 CET 2010


"Joel Goldstick" <joel.goldstick at gmail.com> wrote

>>    def __getattr__(self, attr):
>>        # Fake a __getstate__ method that resturns None
>>        if attr == "__getstate__":
>>            return lambda: None
> 
> why not "return None"?

Presumably the caller is expecting a function that he can call.
The lambda is such a function, but one which always returns 
None.

lambda: None 
is not the same as
None

-- 
Alan Gauld
Author of the Learn to Program web site
http://www.alan-g.me.uk/




More information about the Tutor mailing list