[Python-ideas] Re: The Pattern Matching Wildcard Is A Bad Idea

2021-06-02 Thread Chris Angelico
On Wed, Jun 2, 2021 at 1:17 PM Julia Schmidt wrote: > > From https://docs.python.org/3.10/whatsnew/3.10.html: > > def http_error(status): > match status: > case 400: > return "Bad request" > case 404: > return "Not found" > case 418: >

[Python-ideas] Re: The Pattern Matching Wildcard Is A Bad Idea

2021-06-02 Thread Henk-Jaap Wagenaar
This was discussed/litigated/holy wars fought over at extreme length, I suggest you peruse the email archives searching for PEP 622 or 634 and also this might be a helpful jumping off point: https://github.com/gvanrossum/patma/issues. On Wed, 2 Jun 2021 at 04:18, Julia Schmidt wrote: > From http

[Python-ideas] Re: Add "try: stmt except: stmt" syntax to Python

2021-06-02 Thread Shreyan Avigyan
I want to propose a try-except expression to handle expression errors not stmt errors (Yes I initially proposed stmt but now I'm changing it to expressions after I researched a little more and found it would make a whole lot of sense for expressions.). For example - var if var else var2 - will r

[Python-ideas] Re: Add "try: stmt except: stmt" syntax to Python

2021-06-02 Thread Steven D'Aprano
On Wed, Jun 02, 2021 at 08:58:36AM -, Shreyan Avigyan wrote: > I want to propose a try-except expression to handle expression errors Okay. What has changed since PEP 463 to justify writing a new PEP? https://www.python.org/dev/peps/pep-0463/ -- Steve _

[Python-ideas] Re: Add "try: stmt except: stmt" syntax to Python

2021-06-02 Thread Shreyan Avigyan
Hmmm. Didn't show up as a search result. Yet I feel like it's really to good to have that feature. (Again, it's the PEP dictator's decision.) :-( ___ Python-ideas mailing list -- [email protected] To unsubscribe send an email to python-ideas-le...@

[Python-ideas] Re: Add "try: stmt except: stmt" syntax to Python

2021-06-02 Thread Chris Angelico
On Wed, Jun 2, 2021 at 7:01 PM Shreyan Avigyan wrote: > > I want to propose a try-except expression to handle expression errors not > stmt errors (Yes I initially proposed stmt but now I'm changing it to > expressions after I researched a little more and found it would make a whole > lot of sen

[Python-ideas] Re: Add "try: stmt except: stmt" syntax to Python

2021-06-02 Thread Shreyan Avigyan
Reply to Chris: My Browser showed "No results" and a windows error sound could be heard. I couldn't find the PEP. If I did I would have studied a lot. I didn't have any idea this idea was proposed before and also had a PEP (unfortunately rejected) ___

[Python-ideas] Re: The Pattern Matching Wildcard Is A Bad Idea

2021-06-02 Thread Alexis Masson
Hey everyone, I meant to say, I agree with the two of you, actually. `_` as a variable name is terrible, but it /can/ be used all the same ; on the other hand, wildcards should not be legitimate variable names, to prevent misunderstandings / accidents / bugs. Had I taken part in the discussi

[Python-ideas] Re: The Pattern Matching Wildcard Is A Bad Idea

2021-06-02 Thread Steven D'Aprano
On Wed, Jun 02, 2021 at 01:18:30PM +0200, Alexis Masson wrote: > Anyway, yes, `_` as joker has flaws, the biggest one being to be a > resolvable variable name ; what is the expected behaviour when running a > script that has (even accidentally) a viariable named `_` ? The question > is even mor

[Python-ideas] Re: The Pattern Matching Wildcard Is A Bad Idea

2021-06-02 Thread Alexis Masson
Yeah, that's it exactly. I see these two features - `_` as a joker in `match` statements and `_`as the last value produced by a shell - as incompatible, because you have to account for interferences between them, or face unexpected behaviors in code you run. I expect people to code like I do

[Python-ideas] Re: The Pattern Matching Wildcard Is A Bad Idea

2021-06-02 Thread Jelle Zijlstra
El mié, 2 jun 2021 a las 8:34, Alexis Masson () escribió: > Yeah, that's it exactly. > > I see these two features - `_` as a joker in `match` statements and `_`as > the last value produced by a shell - as incompatible, because you have to > account for interferences between them, or face unexpecte

[Python-ideas] Re: The Pattern Matching Wildcard Is A Bad Idea

2021-06-02 Thread Damian Shaw
> You'd expect code that runs in a shell to behave the same in a script, and vice-versa. But, if `_` is both a variable (shell) and a keyword (`match`), that 's not the case. You have to work around the problem, e.g. by reaffecting `_`. But the discrepancy here is not the match statement, it's tha

[Python-ideas] Re: The Pattern Matching Wildcard Is A Bad Idea

2021-06-02 Thread Shreyan Avigyan
Reply to Alexis Masson: There's no way we can end up in an undefined state. Python just detects if _ is there, it doesn't use it's value. If it is there it's a wildcard pattern. ___ Python-ideas mailing list -- [email protected] To unsubscribe sen

[Python-ideas] Re: Add "try: stmt except: stmt" syntax to Python

2021-06-02 Thread Stephen J. Turnbull
Shreyan Avigyan writes: > My Browser showed "No results" and a windows error sound could be > heard. I couldn't find the PEP. If I did I would have studied a > lot. I didn't have any idea this idea was proposed before and also > had a PEP (unfortunately rejected) You're very close to the lead

[Python-ideas] Re: Add "try: stmt except: stmt" syntax to Python

2021-06-02 Thread Steven D'Aprano
On Thu, Jun 03, 2021 at 02:11:29AM +0900, Stephen J. Turnbull wrote: > What Chris is suggesting is that several of the ideas you've proposed > have had PEPs, or related ideas have had PEPs, so you would benefit > from just reading the list of PEPs. Its not just the PEPs, there are about two decad