Title: Except clause
Type: enhancement Stage: resolved
Components: Versions: Python 3.9
Status: closed Resolution: postponed
Dependencies: Superseder:
Assigned To: Nosy List: eric.smith, xtreak, Артур Григорьев
Priority: normal Keywords:

Created on 2019-07-21 12:07 by Артур Григорьев, last changed 2019-07-21 14:55 by eric.smith. This issue is now closed.

Messages (3)
msg348238 - (view) Author: Артур Григорьев (Артур Григорьев) Date: 2019-07-21 12:07
Is is possible to add to Python the following syntax (keyword 'except'):
[1, 2, 3, 4, 5] except [2]
>>> [1, 3, 4, 5]
msg348243 - (view) Author: Karthikeyan Singaravelan (xtreak) * (Python committer) Date: 2019-07-21 13:06
I guess you are popping 2 from the list and using except for the same. New syntax and semantics needs to be discussed in python-ideas mailing list. Though this reads like English except is used for exception based semantics. I would propose closing this and reopen if it's agreed by core devs in the mailing list.
msg348248 - (view) Author: Eric V. Smith (eric.smith) * (Python committer) Date: 2019-07-21 14:55
Yes, this should be discussed on python-ideas first, so I'm closing it here.

But to be honest with you, there's really no chance this would get accepted. It's just too easy to do it with existing list comprehension syntax, which is much more general purpose.

>>> [v for v in [1, 2, 3, 4, 5] if not v in [2]]
[1, 3, 4, 5]
Date User Action Args
2019-07-21 14:55:21eric.smithsetstatus: open -> closed

nosy: + eric.smith
messages: + msg348248

resolution: postponed
stage: resolved
2019-07-21 13:06:37xtreaksetnosy: + xtreak
messages: + msg348243
2019-07-21 12:07:04Артур Григорьевcreate