Re: for -- else: what was the motivation?

2022-10-15 Thread Grant Edwards
On 2022-10-12, Rob Cliffe via Python-list  wrote:
> 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.

I use it a few times year. I have to look it up in the documentation
every single time I do, and I always add a comment in the "else"
clause stating whether the looped completed "normally" or not.

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


RE: for -- else: what was the motivation?

2022-10-15 Thread avi.e.gross
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.

-Original Message-
From: Python-list  On 
Behalf Of Rob Cliffe via Python-list
Sent: Wednesday, October 12, 2022 6:20 PM
To: [email protected]
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  
> on behalf of Stefan Ram 
> Date: Wednesday, October 12, 2022 at 2:22 PM
> To: [email protected] 
> Subject: Re: for -- else: what was the motivation?
> *** Attention: This is an external email. Use caution responding, 
> opening attachments or clicking on links. ***
>
> Axy  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://urldefense.com/v3/__https://mail.python.org/mailman/listinfo/p
> ython-list__;!!Cn_UX_p3!iyDac-XjNlj78G0XwNzZ-FEHyuCZIy33n3cI9MUDM_FnEd
> R04mSQ5Ln0OA1ETUNloyH24iY9meNHVdixLgWRYL8$ _https:/mail.python.org/mailman/listinfo/python-list__;!!Cn_UX_p3!iyDa
> c-XjNlj78G0XwNzZ-FEHyuCZIy33n3cI9MUDM_FnEdR04mSQ5Ln0OA1ETUNloyH24iY9me
> NHVdixLgWRYL8$>

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

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


Re: Find the path of a shell command [POSTPONED]

2022-10-15 Thread Dan Stromberg
On Wed, Oct 12, 2022 at 9:57 PM Cameron Simpson  wrote:

> On 13Oct2022 03:25, Paulo da Silva 
> wrote:
> >There is another problem involved. The script, works fine except when
> >launched by cron! Why?
>
> Record the script output:
>
>  # record all output
>  exec >/tmp/script.$$.out 2>&1
>  # dump the envionment
>  env | sort
>  # turn on execution tracing
>  set -x
>  ... rest of the script
>
> and have a look afterwards. Cron's environment is very minimal. This
> will show you what's in it.
>

Careful.  On some systems if someone restarts the cron daemon, it could
pick up a larger environment than after being started on boot.
-- 
https://mail.python.org/mailman/listinfo/python-list