[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

[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 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: 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
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 -- python-ideas@python.org To unsubscribe send an email to python-ideas-le...@

[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
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-01 Thread Shreyan Avigyan
Reply to Chris: Yes you're right, I meant if-else expression. ___ Python-ideas mailing list -- python-ideas@python.org To unsubscribe send an email to python-ideas-le...@python.org https://mail.python.org/mailman3/lists/python-ideas.python.org/ Message a

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

2021-06-01 Thread Chris Angelico
On Wed, Jun 2, 2021 at 10:59 AM Steven D'Aprano wrote: > > On Wed, Jun 02, 2021 at 10:47:46AM +1000, Chris Angelico wrote: > > > I can understand the confusion though, given that the parallel > > constructs cited for justification are all expressions. > > "conditional statement, list comprehension

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

2021-06-01 Thread Steven D'Aprano
On Wed, Jun 02, 2021 at 10:47:46AM +1000, Chris Angelico wrote: > I can understand the confusion though, given that the parallel > constructs cited for justification are all expressions. "conditional statement, list comprehensions, dict comprehensions" Two out of three is not bad. Conditional st

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

2021-06-01 Thread Steven D'Aprano
Why do you want this? Is there a shortage of newlines in your country? Maybe the Enter key is broken on your keyboard? *wink* Writing a proposal without a motivation is not very likely to get very far. "Put the code on one line" is not an acceptable motivation; *why* do you want to put it on o

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

2021-06-01 Thread Chris Angelico
On Wed, Jun 2, 2021 at 10:40 AM Steven D'Aprano wrote: > > On Tue, Jun 01, 2021 at 04:30:25PM -0400, Steele Farnsworth wrote: > > > This was proposed in 2014 and was rejected: > > https://www.python.org/dev/peps/pep-0463/ > > No, that's a proposal for a Python *expression* that can be imbedded in

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

2021-06-01 Thread Steven D'Aprano
On Tue, Jun 01, 2021 at 04:30:25PM -0400, Steele Farnsworth wrote: > This was proposed in 2014 and was rejected: > https://www.python.org/dev/peps/pep-0463/ No, that's a proposal for a Python *expression* that can be imbedded in another expression. Shreyan's proposal here is just to allow fitti

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

2021-06-01 Thread Steele Farnsworth
This was proposed in 2014 and was rejected: https://www.python.org/dev/peps/pep-0463/ That being said, I would support such a thing being added to the language. My preferred syntax would be `try expression except ExceptionType [as e] with alternative`, or even `expression except ExceptionType [as