Match.groupdict: Meaning of default argument?

Loris Bennett loris.bennett at fu-berlin.de
Tue May 3 07:37:58 EDT 2022


ram at zedat.fu-berlin.de (Stefan Ram) writes:

> "Loris Bennett" <loris.bennett at fu-berlin.de> writes:
>>I thought that 'days' would default to '0'.
>
>   It will get the value '0' if (?P<days>\d*) does 
>   /not/ participate in the match.
>
>   In your case, it /does/ participate in the match,
>   \d* matching the empty string.
>
>   Try (?P<days>\d+)?.

Ah, thanks.  I was misunderstanding the meaning of 'participate'.

Cheers,

Loris

-- 
This signature is currently under construction.


More information about the Python-list mailing list