On 25/09/05, Andrei <[EMAIL PROTECTED]> wrote:
> > Think the mail system screwed up the formatting! But am fairly sure
> > that I have indented it correctly in the console. Try and Except are
> > in the column. Any other hints?
>
> Yes :). Compare:
>
>  >>> try:
> ...   os.system('cls')
> ... except:
> ...   print "Foo"
> ...
> Foo
>  >>> print "Bar"
> Bar
>
> With (what you had):
>
>  >>> try:
> ...   os.system('cls')
> ... except:
> ...   print "Foo"
> ... print "Bar"
>    File "<stdin>", line 5
>      print "Bar"
>          ^
> SyntaxError: invalid syntax
>
> Subtle, but important difference. You should terminate the try-except
> block (confirm with extra ENTER) before doing more stuff.

When I have this piece of code in a function, it works fine. So is
this some limitation of directly working out off the console?

Seems the console supports complete code constructs only  I.e., I can
have one complete try...except block, a if block etc., but not a bunch
of constructs? Is my assumption correct?

Thanks.

>
> --
> Yours,
>
> Andrei
_______________________________________________
Tutor maillist  -  [email protected]
http://mail.python.org/mailman/listinfo/tutor

Reply via email to