Re: "also" to balance "else" ?

2005-06-16 Thread Tim Roberts
Nicolas Fleury <[EMAIL PROTECTED]> wrote: > >But the feature is already there: > >for x in : > BLOCK1 > if : > ALSO-BLOCK > break >else: > BLOCK2 I've been using Python for 8 years. I never knew that feature was in there. -- - Tim Roberts, [EMAIL PROTECTED] Providen

Re: "also" to balance "else" ?

2005-06-15 Thread Ron Adam
Nicolas Fleury wrote: > Ron Adam wrote: > >> It occurred to me (a few weeks ago while trying to find the best way >> to form a if-elif-else block, that on a very general level, an 'also' >> statement might be useful. So I was wondering what others would think >> of it. > > But the feature i

Re: "also" to balance "else" ?

2005-06-15 Thread Ron Adam
Terry Hancock wrote: > On Wednesday 15 June 2005 03:57 am, Fredrik Lundh wrote: > >>where your "abnormal behaviour" is, of course, the expected >>behaviour. if you insist on looking at things the wrong way, >>things will look reversed. > > Unfortunately, the converse is true, too: no matter how

Re: "also" to balance "else" ?

2005-06-15 Thread Nicolas Fleury
Ron Adam wrote: > It occurred to me (a few weeks ago while trying to find the best way to > form a if-elif-else block, that on a very general level, an 'also' > statement might be useful. So I was wondering what others would think > of it. But the feature is already there: for x in : BLO

Re: "also" to balance "else" ?

2005-06-15 Thread Ron Adam
Fredrik Lundh wrote: > Ron Adam wrote: > > >>So the (my) confusion comes from the tendency to look at it in terms of >>overall program flow rather than in terms of the specific conditional >>logic. >> >>In a for loop the normal, as in terminating normally, behavior of a loop >>is one where the lo

Re: "also" to balance "else" ?

2005-06-15 Thread Terry Hancock
On Wednesday 15 June 2005 03:57 am, Fredrik Lundh wrote: > where your "abnormal behaviour" is, of course, the expected > behaviour. if you insist on looking at things the wrong way, > things will look reversed. Unfortunately, the converse is true, too: no matter how twisted an idea is, you can ma

Re: "also" to balance "else" ?

2005-06-15 Thread Fredrik Lundh
Ron Adam wrote: > So the (my) confusion comes from the tendency to look at it in terms of > overall program flow rather than in terms of the specific conditional > logic. > > In a for loop the normal, as in terminating normally, behavior of a loop > is one where the loop test evaluates as 'False'

Re: "also" to balance "else" ?

2005-06-14 Thread Ron Adam
Andrew Dalke wrote: > As someone else pointed out, that problem could be resolved in > some Python variant by using a different name, like "at end". > Too late for anything before P3K. It was pointed out to me the logic of the else is consistant with the if in reguard to the loop test it self, i

Re: "also" to balance "else" ?

2005-06-14 Thread Ron Adam
Sion Arrowsmith wrote: > Fredrik Lundh <[EMAIL PROTECTED]> wrote: >>nope. else works in exactly the same way for all statements that >>support it: if the controlling expression is false, run the else suite >>and leave the statement. > > > For example, consider the behaviour of: > > condition =

Re: "also" to balance "else" ?

2005-06-14 Thread TZOTZIOY
On Tue, 14 Jun 2005 07:20:06 GMT, rumours say that Andrew Dalke <[EMAIL PROTECTED]> might have written: >Given the Python maxim of > There should be one-- and preferably only one --obvious way to do it. > >which of these is the preferred and obvious way? > >while f(): > print "Hello!" > if g():

Re: "also" to balance "else" ?

2005-06-14 Thread John Roth
"Andrew Dalke" <[EMAIL PROTECTED]> wrote in message news:[EMAIL PROTECTED] > Ron Adam wrote: >> True, but I think this is considerably less clear. The current for-else >> is IMHO is reversed to how the else is used in an if statement. > > As someone else pointed out, that problem could be resolv

Re: "also" to balance "else" ?

2005-06-14 Thread Sion Arrowsmith
Fredrik Lundh <[EMAIL PROTECTED]> wrote: >Ron Adam wrote: >> True, but I think this is considerably less clear. The current for-else >> is IMHO is reversed to how the else is used in an if statement. >nope. else works in exactly the same way for all statements that >support it: if the controlling

Re: "also" to balance "else" ?

2005-06-14 Thread Fredrik Lundh
Terry Hancock wrote: > Personally, though, "for-finally" would make a lot more sense > to me than "for-else" (and I don't have enough "for-else" code > to worry about it breaking). "finally" means "run this piece of code no matter what happens in the previous block". that's not how "else" works

Re: "also" to balance "else" ?

2005-06-14 Thread Fredrik Lundh
Ron Adam wrote: > True, but I think this is considerably less clear. The current for-else > is IMHO is reversed to how the else is used in an if statement. nope. else works in exactly the same way for all statements that support it: if the controlling expression is false, run the else suite and

Re: "also" to balance "else" ?

2005-06-14 Thread Andrew Dalke
Terry Hancock wrote: > No, I know what it should be. It should be "finally". It's already > a keyword, and it has a similar meaning w.r.t. "try". Except that a finally block is executed with normal and exceptional exit, while in this case you would have 'finally' only called when the loop exite

Re: "also" to balance "else" ?

2005-06-14 Thread Andrew Dalke
Ron Adam wrote: > True, but I think this is considerably less clear. The current for-else > is IMHO is reversed to how the else is used in an if statement. As someone else pointed out, that problem could be resolved in some Python variant by using a different name, like "at end". Too late for an

Re: "also" to balance "else" ?

2005-06-14 Thread Terry Hancock
On Tuesday 14 June 2005 12:07 am, Ron Adam wrote: > Terry Hancock wrote: > > On Monday 13 June 2005 11:09 pm, Ron Adam wrote: > >>My suggestion is to use, also as the keyword to mean "on normal exit" > >>'also' do this. > > Unfortunately, "also" is also a bad keyword to use for this, IMHO. > > I d

Re: "also" to balance "else" ?

2005-06-13 Thread Donn Cave
Quoth Ron Adam <[EMAIL PROTECTED]>: | ... The current for-else | is IMHO is reversed to how the else is used in an if statement. Is that all? As a matter of opinion, this one is fairly simply an arbitrary choice to assign a positive sense to completion of the loop predicate. For search loops, f

Re: "also" to balance "else" ?

2005-06-13 Thread Ron Adam
Terry Hancock wrote: > On Monday 13 June 2005 11:09 pm, Ron Adam wrote: >>My suggestion is to use, also as the keyword to mean "on normal exit" >>'also' do this. > > > Unfortunately, "also" is also a bad keyword to use for this, IMHO. > I don't find it any more intuitive than "else". (And sin

Re: "also" to balance "else" ?

2005-06-13 Thread Ron Adam
Andrew Dalke wrote: > Ron Adam wrote: > >>It occurred to me (a few weeks ago while trying to find the best way to >>form a if-elif-else block, that on a very general level, an 'also' >>statement might be useful. So I was wondering what others would think >>of it. > > >>for x in : >>BLOC

Re: "also" to balance "else" ?

2005-06-13 Thread Terry Hancock
On Monday 13 June 2005 11:09 pm, Ron Adam wrote: > John Roth wrote: > > "Ron Adam" <[EMAIL PROTECTED]> wrote in message > > news:[EMAIL PROTECTED] > > The difficulty you're having with this is that else > > is a very bad keyword for this particular construct. > > I'd prefer something like "on norm

Re: "also" to balance "else" ?

2005-06-13 Thread Ron Adam
John Roth wrote: > > "Ron Adam" <[EMAIL PROTECTED]> wrote in message > news:[EMAIL PROTECTED] > >> Currently the else block in a for loop gets executed if the loop is >> completed, which seems backwards to me. I would expect the else to >> complete if the loop was broken out of. That seems m

Re: "also" to balance "else" ?

2005-06-13 Thread John Roth
"Ron Adam" <[EMAIL PROTECTED]> wrote in message news:[EMAIL PROTECTED] > Currently the else block in a for loop gets executed if the loop is > completed, which seems backwards to me. I would expect the else to > complete if the loop was broken out of. That seems more constant with > if's el

Re: "also" to balance "else" ?

2005-06-13 Thread Ron Adam
Eloff wrote: > My first reaction was that this is terrible, else clauses on loops are > confusing enough. But if I think about it more, I'm warming up to the > idea. Also/Else for loops is clear, symmetrical, and would be useful. > > Reversing the meanign of else will break code, but it's not used

Re: "also" to balance "else" ?

2005-06-13 Thread Andrew Dalke
Ron Adam wrote: > It occurred to me (a few weeks ago while trying to find the best way to > form a if-elif-else block, that on a very general level, an 'also' > statement might be useful. So I was wondering what others would think > of it. > for x in : > BLOCK1 > if : break # do else

Re: "also" to balance "else" ?

2005-06-13 Thread Eloff
My first reaction was that this is terrible, else clauses on loops are confusing enough. But if I think about it more, I'm warming up to the idea. Also/Else for loops is clear, symmetrical, and would be useful. Reversing the meanign of else will break code, but it's not used that frequently, and i

"also" to balance "else" ?

2005-06-13 Thread Ron Adam
There seems to be a fair amount of discussion concerning flow control enhancements lately. with, do and dowhile, case, etc... So here's my flow control suggestion. ;-) It occurred to me (a few weeks ago while trying to find the best way to form a if-elif-else block, that on a very general