Mailing List Archive

[issue37643] Except clause
New submission from ????? ????????? <agsci2017@gmail.com>:

Is is possible to add to Python the following syntax (keyword 'except'):
[1, 2, 3, 4, 5] except [2]
>>> [1, 3, 4, 5]

----------
messages: 348238
nosy: ????? ?????????
priority: normal
severity: normal
status: open
title: Except clause
type: enhancement
versions: Python 3.9

_______________________________________
Python tracker <report@bugs.python.org>
<https://bugs.python.org/issue37643>
_______________________________________
_______________________________________________
Python-bugs-list mailing list
Unsubscribe: https://mail.python.org/mailman/options/python-bugs-list/list-python-bugs%40lists.gossamer-threads.com
[issue37643] Except clause [ In reply to ]
Karthikeyan Singaravelan <tir.karthi@gmail.com> added the comment:

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.

----------
nosy: +xtreak

_______________________________________
Python tracker <report@bugs.python.org>
<https://bugs.python.org/issue37643>
_______________________________________
_______________________________________________
Python-bugs-list mailing list
Unsubscribe: https://mail.python.org/mailman/options/python-bugs-list/list-python-bugs%40lists.gossamer-threads.com
[issue37643] Except clause [ In reply to ]
Eric V. Smith <eric@trueblade.com> added the comment:

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]

----------
nosy: +eric.smith
resolution: -> postponed
stage: -> resolved
status: open -> closed

_______________________________________
Python tracker <report@bugs.python.org>
<https://bugs.python.org/issue37643>
_______________________________________
_______________________________________________
Python-bugs-list mailing list
Unsubscribe: https://mail.python.org/mailman/options/python-bugs-list/list-python-bugs%40lists.gossamer-threads.com