Who's minister of propaganda this week?
Joshua Marshall
jmarshal at mathworks.com
Wed Mar 14 12:49:08 EST 2001
Darren New <dnew at san.rr.com> wrote:
> Phlip wrote:
>> Ruby trumps Python in the simple matter of
>> closures (imagine my shock when I discovered Python didn't have them).
> Can someone summarize the important difference between closures and object
> instances? Other than convenience, I mean, it would seem that something like
> class yadda:
> def __init__(self, a, b):
> self.a = a ; self.b = b
> def __call__(self, x, y):
> return (self.a + x * self.b * y)
> would seem to be quite a lot like a closure with a and b bound and x and y
> free?
Yup. Object instances and closures are very similar. Scoping issues
aside, you can think of closures as classless instances with only one
method.
More information about the Python-list
mailing list