why it is invalid syntax?

Stef Mientki S.Mientki-nospam at mailbox.kun.nl
Thu Nov 22 04:17:07 EST 2007


alf 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 :
> 
> 

Although I agree it might be quit unreadable for normal programmers,
people who are used to writing math formula, (i.e. MatLab),
this is not true.

Here another interesting one, that is accepted:

         self.nodes.extend ( [ ONode(shape,n,self) \
                               for n in range(shape.Parent.N_Outputs) \
                               if shape.Type_Outputs[n] == type ] )

cheers,
Stef



More information about the Python-list mailing list