def start():
.... lots of lines...
    global xaxis
    global yaxis

Its traditional to put global statements at the top of the function. Also you only need one line to list all of the global variables

    global radiusaxis
    global radiusaxis2

What, like global radiusaxis, radiusaxis2

Similarly here., and again you can put all four in one place.

radiusaxis2.visible = 0

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.

def graphit(type,f,range2,step):
    li = curve(color=color.blue)
    if type in ['y','x']:
        x = -15
        radiusaxis.visible = 0
        radiusaxis2.visible = 0
        while -15 <= x <= 15:
            if eval(range2):
                try:
                    a = f(x)
                    if -15 <= a <= 15:
                        if type == 'y':
                            li.append(pos=(x,a,0))
                        elif type == 'x':
                            li.append(pos=(a,x,0))
                    else:
                        li = curve(color=color.blue)
                except:
                    pass

This is iffy. If *anthing* happens you ignore it. Now suppose due to a bug you go into an infinite loop and you try to stop using CTRL-C - it won't work!

If you must use a catch-all except then do something
with it - print a message at least!

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. Otherwise I wouldn't need it.



I got a sore head after that... I'll leave the rest for
others to remark upon. :-)

Alan G.

I'd send some Advil or something, but it doesn't work too well through email. ;-)
Thanks for the help,
Jacob Schmidt





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

Reply via email to