News for hackers. Stuff that matters.
Re:Pattern matching accepted for Python by coldtea on Tuesday February 09, 2021 @09:49PM (#26085262)
>The generator object that gets created behind the scenes.

So like a match object that could get crreated behind the scenes?

Re:Pattern matching accepted for Python by pfalcon on Wednesday February 10, 2021 @05:27AM (#26087511)
If you have automatic block-level scoping, then you have the opposite problem - you need to do extra leg-work to communicate a value to the surrounding scope.

Anyway, anyone agrees that block-level scoping is useful. Interested in block-level scoping in Python? Please post on the python-ideas mailing list. Thanks.

Re:Pattern matching accepted for Python by coldtea on Wednesday February 10, 2021 @05:42AM (#26087600)
>If you have automatic block-level scoping, then you have the opposite problem - you need to do extra leg-work to communicate a value to the surrounding scope.

In the general case, you just declare the variable in the surrounding scope and then affect it in the lower one, no?

Re:Pattern matching accepted for Python by pfalcon on Wednesday February 10, 2021 @06:00AM (#26087689)
Right. But the whole idea of Python scoping rules was to not burden people with the need to declare variables (instead, if you define one, it's accessible everywhere in the function).

But yes, block-level scoping (as in C for example) would be useful too in addition to existing whole-function scoping discipline.

Again, I'm looking for similarly-minded people to move this idea forward. If interested, please find me on the python-ideas mailing list for discussing details.

Re:Pattern matching accepted for Python by jnxx on Wednesday February 10, 2021 @03:36PM (#26094407)
> then you have the opposite problem - you need to do extra leg-work to communicate a value to the surrounding scope.

that would be far less likely to break things in an unexpected way, as in "explicit is better than implicit".

I am also wondering whether what is really missing here is perhaps a kind of imperative switch/case statement which has the explicit purpose of changing function variables.