On 2022-10-15 23:50, avi.e.gr...@gmail.com wrote:
This has been discussed so often precisely because I swear NO CHOICE of keyword 
would satisfy everybody! Most languages start with designated keywords and some 
reserve a few for later use. But then things can get frozen in place to avoid 
breaking existing programs or break older compilers/interpreters.

Some languages use techniques to extend themselves more harmlessly such as creating a 
singleton object that has content that can be regular data as in math.pi, or 
functions/methods or new ides like "Symbols" that allow all kinds of extensions 
to the language in a fairly harmless way as no older program would likely have used 
features that did not exist.

That might not easily solve this problem. But I wonder if reserving some kind 
of prefix might help, so anything like extension.0nNoBreak could be added to a 
loop as a final clause and be treated as a non-key keyword of sorts.

If you'd accept 2 words:

    for child in tree.getroot():
        if child.tag == 'server':
            break
    not break:
        raise ValueError(f"server tag not found in {lfile}")

-----Original Message-----
From: Python-list <python-list-bounces+avi.e.gross=gmail....@python.org> On 
Behalf Of Rob Cliffe via Python-list
Sent: Wednesday, October 12, 2022 6:20 PM
To: python-list@python.org
Subject: Re: for -- else: what was the motivation?

I too have occasionally used for ... else.  It does have its uses. But oh, how I wish it had been 
called something else more meaningful, whether 'nobreak' or whatever.  It used to really confuse 
me.  Now I've learned to mentally replace "else" by "if nobreak", it confuses 
me a bit less.
Rob Cliffe

On 12/10/2022 22:11, Weatherby,Gerard wrote:
As did I.

tree = ET.parse(lfile)
             for child in tree.getroot():
                 if child.tag == 'server':
                     break
             else:
                 raise ValueError(f"server tag not found in {lfile}")

I think there are other places I could be using it, but honestly I tend to 
forget it’s available.

From: Python-list <python-list-bounces+gweatherby=uchc....@python.org> on behalf of Stefan Ram <r...@zedat.fu-berlin.de>
Date: Wednesday, October 12, 2022 at 2:22 PM
To: python-list@python.org <python-list@python.org>
Subject: Re: for -- else: what was the motivation?
*** Attention: This is an external email. Use caution responding, opening attachments or clicking on links. ***

Axy <a...@declassed.art> writes:
So, seriously, why they needed else if the following pieces produce same result? Does anyone know or remember their motivation?
   Just wrote code wherein I used "else"! This:

import locale
for name in( 'de', 'de_DE', 'deu_deu', 'deu', 'German', 'Deutsch' ):
     try: locale.setlocale( locale.LC_ALL, name ); break
     except locale.Error: pass
else: print( "Programm kann deutsche Schreibweise nicht einrichten." )

   .


--
https://mail.python.org/mailman/listinfo/python-list

Reply via email to