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
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
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
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
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
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
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'
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
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 =
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():
"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
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
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
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
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
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
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
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
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
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
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
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
"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
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
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
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
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
27 matches
Mail list logo