[Python-ideas] Re: Conditional function/method/dict arguments assignments

2020-10-26 Thread Eric V. Smith
That won't work with at least some builtins written in C, and maybe extension modules. I just checked 3.9 and str.count, and inspect.signature fails with ValueError: no signature found for builtin . I don't know if Argument Clinic (AC) would improve this, or maybe it's outside of what AC can

[Python-ideas] Re: Conditional function/method/dict arguments assignments

2020-10-26 Thread jan . thor
I wouldn't call it tricky, it's actually quite straightforward: import inspect def extract_default(function, parameter): sig = inspect.signature(function) param = sig.parameters[parameter] return param.default def do_something(count=5): print(count)

[Python-ideas] Re: Conditional function/method/dict arguments assignments

2020-10-25 Thread Shai Berger
I've been toying with a similar idea myself. I've felt the pain described by Brian, and I share Marco's dislike for the suggested syntax. Moreover, I dislike the idea that the conditional should somehow refer to the function's default arguments. My half-baked idea is along the lines of

[Python-ideas] Re: Conditional function/method/dict arguments assignments

2020-10-24 Thread Marco Sulla
I had many times the same idea: why can't we just "say" to the called function "use your own default"? I'm quite sure this is possible in a tricky way, since defaults are stored in the function object. Anyway, honestly I don't like your syntax proposal.