Home

Bruno Desthuilliers wrote:
>
> Most of what you can do with a callable instance can be done with
> closures (and is usually done so in FPLs), but given Python's OO nature,
> it's sometimes clearer and simpler to use callable instances than
> closures.

Indeed. I think __call__ has been neglected as closures have become
more widely used. In all cynicism, however, I'd argue that with
Python's very usable implementation of object-orientation, classes
with __call__ methods frequently make for clearer demonstrations of
solutions than closures do, despite requiring slightly more characters
of source code, and in contrast to the apparent fashion for using
closures for showing off more or less everything these days (despite
various pitfalls which may seem counter-intuitive to the beginner).

Paul

previous
next

Something in the function tutorial confused me.
using decl, force to file scope only in header file
Re: status of Programming by Contract (PEP 316)?
Re: Fast kNN from python
why memory leak here?
Fundacja Avalon
Pajacyk
Akogo
Krwinka
Nasze Dzieci