Help with new scope problem

Luis Cortes lcortes at
Sun Mar 18 23:02:56 CET 2001


I have a piece of code that I think should work fine, but I believe that
I've hit a scope problem (Python 2.1b1).  Does anyone out there have a hint
as to how to fix it??


def getarguments():

        box = ( 160, 120 )
        newgifname = 'new.gif'
        gifname = ''

        if (len(sys.argv) < 4 ):
                print 'usage: width height newimage.gif'

        if (len(sys.argv) > 4):
                # program width, height,, newimage.gif
                box = ( int(sys.argv[1]), int(sys.argv[2]) )
                gifname = sys.argv[3]

        if (len(sys.argv) > 5 ):
                newgifname = sys.argv[4]

        print box, gifname, newgifname
        return ( box, gifname, newgifname )

THE PROBLEM:  when I have more than 3 arguments, the global variables do not
change to the correct variables, but instead print their default values.

More information about the Python-list mailing list