On Mon, Apr 27, 2015 at 2:45 PM, Ethan Furman <et...@stoneleaf.us> wrote:
>> What's the advantage of that over a simple closure? You have the same
>> number of nesting levels, plus a lot more boiler-plate repetition -
>> instead of just referencing names from the outer scope, you have to
>> explicitly capture them all with "self.n=n" for each one. I'm not sure
>> you really even gain much clarity.
>>
>> In a way, a closure is a short-hand for an object with a __call__
>> method that auto-captures all its local variables.
>
> I find it much easier to keep track of what is going on, especially in
> those cases where there is pre-, post-, or both, processing going on.
>
> YMMV.

Perhaps in the complicated cases, but in the common and simple case
that the OP's talking about (where the purpose of the outermost
function is solely to capture arguments for the next level in), I
wouldn't bother with a class.

But as you say, YMMV.

ChrisA
-- 
https://mail.python.org/mailman/listinfo/python-list

Reply via email to