News for hackers. Stuff that matters.
Re:What’s New in Python 3.8 by Tommah on Monday October 14, 2019 @08:50PM (#21254500)
There is a similar trick that you can use without the walrus operator. I wrote the code many years ago and I am reproducing this from memory, so the code below may be a little off. Define this class:

    class Any:
        def __eq__(self, other):
            self.value = other
            return True
Then you can use an instance of it as the hole in a pattern. My use case was performing peephole optimizations in a simple 6502 assembler. For example, if the LDA operation (load value from memory location into accumulator) occurs twice in a row, the first load is redundant. So I did this test:

    x, y = Any(), Any()
    if L[i:i+2] == [('LDA', x), ('LDA', y)]:
        L[i:i+2] = [('LDA', y.value)]
(Note that the last line changes the length of the list, so it may be slow on large lists.)

I was going to write a blog post about this back then, but I never did. If anyone is interested, I can write it now.

Re:What’s New in Python 3.8 by eru on Tuesday October 15, 2019 @02:19AM (#21255976)
But that breaks normal equality tests for your type?
Re:What’s New in Python 3.8 by heavenlyblue on Tuesday October 15, 2019 @04:46AM (#21256656)
Wouldn’t parent’s code simply copy into Any every time it’s compared in a list?

It is some spooky action at a distance.

Re:What’s New in Python 3.8 by eru on Tuesday October 15, 2019 @06:11AM (#21257065)
Probably. I found it a bit confusing in any case.