Re: "Weird" Indentation? (Or: is there a for...else construct?)

2009-02-08 Thread birdsong
On Feb 7, 6:34 am, Andreas Waldenburger wrote: > On Sun, 08 Feb 2009 01:28:00 +1100 Steven D'Aprano > > wrote: > > Andreas Waldenburger wrote: > > > > It seems that there is a for...else construct. Replacing the inner > > > if with pass seems to confirm this. The else clause is still > > > execut

Re: "Weird" Indentation? (Or: is there a for...else construct?)

2009-02-08 Thread Tim Rowe
2009/2/7 andrew cooke : > > there's a justification for this awful mess here - > http://mail.python.org/pipermail/python-3000/2006-March/000104.html > > i didn't know about this, and even after reading steven's broken (i > assume) example, managed to get it backwards. What's awful about it? Except

Re: "Weird" Indentation? (Or: is there a for...else construct?)

2009-02-07 Thread andrew cooke
there's a justification for this awful mess here - http://mail.python.org/pipermail/python-3000/2006-March/000104.html i didn't know about this, and even after reading steven's broken (i assume) example, managed to get it backwards. the else is if there *isn't* a break and is for search loops (s

Re: "Weird" Indentation? (Or: is there a for...else construct?)

2009-02-07 Thread Diez B. Roggisch
Peter Otten schrieb: Andreas Waldenburger wrote: I've found something in the spirit of the following (in the epydoc sources, if you care): if True: print "outer if" for t in range(2): if True: print "for if" else: print "phantom else" For the life of me

Re: "Weird" Indentation? (Or: is there a for...else construct?)

2009-02-07 Thread MRAB
Andreas Waldenburger wrote: On Sun, 08 Feb 2009 01:28:00 +1100 Steven D'Aprano wrote: Andreas Waldenburger wrote: It seems that there is a for...else construct. Replacing the inner if with pass seems to confirm this. The else clause is still executed. Yes, there is a for...else construct.

Re: "Weird" Indentation? (Or: is there a for...else construct?)

2009-02-07 Thread Andreas Waldenburger
On Sun, 08 Feb 2009 01:28:00 +1100 Steven D'Aprano wrote: > Andreas Waldenburger wrote: > > > It seems that there is a for...else construct. Replacing the inner > > if with pass seems to confirm this. The else clause is still > > executed. > > Yes, there is a for...else construct. > That's som

Re: "Weird" Indentation? (Or: is there a for...else construct?)

2009-02-07 Thread Peter Otten
Andreas Waldenburger wrote: > I've found something in the spirit of the following (in the epydoc > sources, if you care): > > if True: > print "outer if" > for t in range(2): > if True: > print "for if" > else: > print "phantom else" > > For the life of me

Re: "Weird" Indentation? (Or: is there a for...else construct?)

2009-02-07 Thread Steven D'Aprano
Andreas Waldenburger wrote: > It seems that there is a for...else construct. Replacing the inner if > with pass seems to confirm this. The else clause is still executed. Yes, there is a for...else construct. The else block runs if the for loop exits *without* a break. for i in range(20): if

Re: "Weird" Indentation? (Or: is there a for...else construct?)

2009-02-07 Thread Andreas Waldenburger
On Sat, 7 Feb 2009 15:21:22 +0100 Andreas Waldenburger wrote: > outer if > For if > For if > Phantom else > Geez, I'm a moron. This is obviously not the output from the snippet. But if you fix the capitalization, it is. Sorry for that. /W -- My real email address is constructed by swapping th

"Weird" Indentation? (Or: is there a for...else construct?)

2009-02-07 Thread Andreas Waldenburger
I've found something in the spirit of the following (in the epydoc sources, if you care): if True: print "outer if" for t in range(2): if True: print "for if" else: print "phantom else" For the life of me I can't place the "else". Which if clause does it be