On Thu, 22 Nov 2007 00:00:16 -0600, alf <[EMAIL PROTECTED]> wrote: >Hi, > >I wonder why it is an invalid syntax: > > > >>> if 1: if 1: if 1: print 1 > File "<stdin>", line 1 > if 1: if 1: if 1: print 1 > > >or > > >>> if 1: for i in range(10): print i > File "<stdin>", line 1 > if 1: for i in range(10): print i > >I would expect one could nest : >
You may take a look at python documentation, Language reference, 7. Compound statement. It clearly states that what follows the : of if,while,for... if it is not a new line, it should be a list of simple statements. Son no there is no : nesting. >compound_stmt ::= if_stmt > | while_stmt > | for_stmt > | try_stmt > | with_stmt > | funcdef > | classdef >suite ::= stmt_list NEWLINE | NEWLINE INDENT statement+ DEDENT >statement ::= stmt_list NEWLINE | compound_stmt >stmt_list ::= simple_stmt (";" simple_stmt)* [";"] > Regards, Zara -- http://mail.python.org/mailman/listinfo/python-list