It's been a while since this was posted, but a thought:
Here's an idea. At present both of
>
> d[1:2]
>> d[1:2, 3:4, 5, 6]
>> are valid syntax, but neither of
>> d[(1:2)]
>> d[(1:2, 3:4, 5, 6)]
>> are valid syntax. This is, I think, a bit of an anomaly.
>>
>
indeed -- it's been
On Tue, Oct 27, 2020 at 5:01 AM Dennis Sweeney
wrote:
>
> MRAB wrote:
> > The assertions could still fail because there's nothing there to say
> > that a0, b0 and c0 are strings, or, indeed, that there isn't a comma in
> > one of them.
> > .
>
> That's true. But that's a weakness of parsing any
MRAB wrote:
> The assertions could still fail because there's nothing there to say
> that a0, b0 and c0 are strings, or, indeed, that there isn't a comma in
> one of them.
> .
That's true. But that's a weakness of parsing any ambiguous pattern, even with
regular expressions. It would be up to
On 2020-10-26 04:56, Dennis Sweeney wrote:
What if the mapping assignment were more harmonious with the pattern matching
PEP? Something like this:
items = {'eggs': 2, 'cheese': 3, 'spam': 1}
{'eggs': eggs, 'spam': i_dont_need_to_name_this_spam, **rest} = items
assert
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
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)
For some explanation, see this StackOverflow answer by Raymond Hettinger:
https://stackoverflow.com/a/16645307/11461120
___
Python-ideas mailing list -- python-ideas@python.org
To unsubscribe send an email to python-ideas-le...@python.org