[Python-ideas] DBC (Re: Explicit variable capture list)
Chris Angelico
rosuav at gmail.com
Tue Jan 26 10:51:08 EST 2016
On Wed, Jan 27, 2016 at 2:42 AM, Paul Moore <p.f.moore at gmail.com> wrote:
> On 26 January 2016 at 15:24, Chris Angelico <rosuav at gmail.com> wrote:
>> This still
>> has one nasty problem though: the requires and ensures functions can't
>> see function arguments.
>
> See my code - you can put the args onto the instance as attributes for
> requires/ensures to inspect.
Except that there can be only one of those at any given time, so you
run into issues with recursion or threads/async/etc; plus, it's still
not properly clean - you have to check either args or kwargs,
depending on whether the argument was passed positionally or by
keyword. I don't see that as a solution.
(Maybe what we need is a "keyword-to-positional" functools feature -
anything in **kwargs that can be interpreted positionally gets removed
and added to *args. Or the other way - keywordify everything.)
ChrisA
More information about the Python-ideas
mailing list