interpreter use... help?

Paul Sidorsky paulsid at home.com
Mon Aug 6 00:01:37 EDT 2001


CCLittle wrote:

> Here is what I do:
> 
> >>> try:
>            action1()
>            except TypeError:
> 
> SyntaxError: invalid syntax
> >>>
> 
> The except part is highlighted.
> I just can't make the except go one indentation level lower even by pressing
> the backspace!
> Short of putting everything inside a module and importing, is there a way
> around this?

This works for me in IDLE under WinME:

> Python 2.1 (#15, Apr 16 2001, 18:25:49) [MSC 32 bit (Intel)] on win32
> Type "copyright", "credits" or "license" for more information.
> IDLE 0.8 -- press F1 for help
> >>> exc = 0
> >>> try:
>         item = lst[1]
> except:
>         exc = 1
> 
> 
> >>> exc
> 1

The only formatting I had to do was to press backspace once on the except line
which put the cursor in the first column.

Notice that the try and except don't line up visually.  I guess the trick is to
mentally snip out the ">>><space>" part.

I tried in the plain command line interpreter, too.  There you have to do the
tabbing yourself, but you get the "..." prompt so the code does line up.

-- 
======================================================================
Paul Sidorsky                                          Calgary, Canada
paulsid at home.com                      http://members.home.net/paulsid/




More information about the Python-list mailing list