[Tutor] Pythonwin

Magnus Lycka magnus@thinkware.se
Wed Dec 11 18:17:07 2002


At 19:22 2002-12-11 -03-30, Adam Vardy wrote:
>I am trying to run this. Goes to the same menu.

What same menu?
1 Click File -> New.
2 Select "Python script"
3 Paste code
4 Ctrl-S to save (give filename first time)
5 F5 to run (Hm... that's not clearly indicated I guess. But it's
              the run key in all Windows IDE's I ever used.)
6 Switch to Interactive Window
7 Read an interpret traceback
8 Switch back and fix code
9 Go to 4

I'm not sure if you installed ActivePython or Mark's win32all.

In the ActivePython help, look at:
ActivePython User's Guide
   What's included in ActivePython

       PythonWin Development Environment

         Keyboard Bindings

           F5 Run

Remember that "real programmer" don't use the mouse unless
they really have to... Typing at the keyboard is much, much
faster.

>And bottom of screen
>just says Exception raised.  Program still seems good to me. I thought
>it would give more detailed explanation.

It does... Switch over to the interactive window, and you
will see the traceback.

>I haven't actually reached the chapter on exceptions.

All runtime error messages come as exeptions. Reading
tracebacks is fairly clear. I don't think you need to
grok exceptions.

>I could locate a Help section on PythonWin.  It starts off though
>about Modules and Objects. not apropos. The only documentation there
>was a like a page or two. I thought you'd get explanations for all the
>File...Tools menu system.

I guess Mark Hammond though it was self explanatory. ;)

I think you will get used to it fairly quickly.

>L=[1,2,4,8,16,32,64]
>X=5
>
>found = i = 0
>while i< len(L):
>   if 2 ** X==L(i): break

This is where is chokes first. I think you mean L[i]

>   else:
>     i=i+1
>
>##if found:
>   print 'at index',i

When the if-statement is commented out like that,
the next line will cause a syntax error due to the
indetation. You can't suddenly have indented code
without if, while, for, def etc.

>else:
>   print X, 'not found'


-- 
Magnus Lycka, Thinkware AB
Alvans vag 99, SE-907 50 UMEA, SWEDEN
phone: int+46 70 582 80 65, fax: int+46 70 612 80 65
http://www.thinkware.se/  mailto:magnus@thinkware.se