Else statement executing when it shouldnt

Thomas Boell tboell at domain.invalid
Tue Jan 22 10:48:35 EST 2013


On Wed, 23 Jan 2013 02:42:27 +1100
Chris Angelico <rosuav at gmail.com> wrote:

> On Wed, Jan 23, 2013 at 2:39 AM, Thomas Boell <tboell at domain.invalid> wrote:
> > Huh?! I would have expected all your examples to raise a SyntaxError or
> > IndentationError. Why don't they? Is 'else' not required to have a
> > matching 'if'?
> 
> Other things can have else, including 'for' and 'while' loops. :)

I must say, that's bound to be confusing for anyone who knows any
language other than Python (or none, even).  Syntax like that is "an
accident waiting to happen"...



More information about the Python-list mailing list