On Sun, 22 Oct 2023 at 11:29, MRAB wrote:
> I think what the OP wants is to have re.match either return a match or
> raise an exception.
Yes, and my point is that simply attempting to access an attribute
will do exactly that. It's not a silent failure.
Why create a new argument, then mandate tha
On 2023-10-21 21:15, Chris Angelico wrote:
On Sun, 22 Oct 2023 at 06:37, Ram Rachum wrote:
On Sat, Oct 21, 2023 at 10:30 PM Chris Angelico wrote:
> I love that, but it mostly makes sense for "if there's a match do this, otherwise do that" where
most cases fall into "I'm absolutely sure th
On Sun, 22 Oct 2023 at 06:37, Ram Rachum wrote:
>
> On Sat, Oct 21, 2023 at 10:30 PM Chris Angelico wrote:
>>
>>
>> > I love that, but it mostly makes sense for "if there's a match do this,
>> > otherwise do that" where most cases fall into "I'm absolutely sure there's
>> > a match here and her
On Sat, Oct 21, 2023 at 10:30 PM Chris Angelico wrote:
>
> > I love that, but it mostly makes sense for "if there's a match do this,
> otherwise do that" where most cases fall into "I'm absolutely sure there's
> a match here and here's what we should do with that match", and when that
> "absolute
On Sun, 22 Oct 2023 at 06:11, Ram Rachum wrote:
>
> On Sat, Oct 21, 2023 at 10:01 PM Chris Angelico wrote:
>>
>> On Sat, 21 Oct 2023 at 21:57, Ram Rachum wrote:
>>
>> What about an if with the match inside it?
>>
>> if m := re.match(...):
>> ...
>>
>> That's one of the motivating examples be
On Sat, Oct 21, 2023 at 10:01 PM Chris Angelico wrote:
> On Sat, 21 Oct 2023 at 21:57, Ram Rachum wrote:
>
> What about an if with the match inside it?
>
> if m := re.match(...):
> ...
>
> That's one of the motivating examples behind the walrus after all.
>
I love that, but it mostly makes
On Sat, 21 Oct 2023 at 21:57, Ram Rachum wrote:
>
> It's a little similar to the reasoning behind PEP 618 (adding the `strict`
> argument to `zip`).
Not quite, since without strict, zip will truncate - it doesn't have a
different return value.
> A keyword argument is easier to add, and makes th
It's a little similar to the reasoning behind PEP 618 (adding the `strict`
argument to `zip`).
A keyword argument is easier to add, and makes the code less ugly, then an
`if` clause. When I don't have that `if` clause you mentioned in my code,
it's not because I forgot, it's because I don't want a
I feel like this is all example of "not every one line function needs to be
in the standard library."
You can easily write your own 'match_or_raise()'... I guess it would take
two lines, actually.
On Sat, Oct 21, 2023, 2:42 PM Ram Rachum wrote:
> Hey,
>
> I bet this has been discussed before bu
I don't see how it's more likely that people would remember to add a
`require=True` flag than to add `if m: raise RuntimeError("No match")`. The
problem here is people forgetting that a match can fail, not lack of a
means to handle that problem.
Paul
On Sat, 21 Oct 2023 at 11:38, Ram Rachum wrot
Hey,
I bet this has been discussed before but I couldn't find it. I'd appreciate
it if anyone could point me to that thread.
I'm sick of seeing "AttributeError: 'NoneType' object has no attribute
'foo'" whenever there's a `re.match` operation that fails while the code
expects it to succeed. What
11 matches
Mail list logo