[Tutor] Better structure?

Alan Gauld alan.gauld at freenet.co.uk
Tue Feb 1 22:12:09 CET 2005


> What, like
> global radiusaxis, radiusaxis2

exactly.

> > And since there is no input parameter and no return statement
> > and you only call start() once...
>
> Not true. If y == 'clear', then start is called to "redraw" the
window.
> Very important part.

OK, I missed that, but its still better to hide the call to
start inside an
if name== main
clause since otherwise you can't ever import your file without
drawing the screen.

> I think I'll do that, but of course I'll have to add ValueError -- 
because
> of math domain errors on my function. That's what the try except
block is for.

In that case just put the ValueError clause in and leave other erors
to raise an error stack - that way you get to see the source of
the problem.

Then wrap your call to start in a try/except to catch the errors
and print a message at the outer level. That way its easy to turn
error reporting on/off

Alan G.



More information about the Tutor mailing list