Help with new scope problem

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


Hello,

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??

code:

def getarguments():

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

        if (len(sys.argv) < 4 ):
                print 'usage: trans.py width height image.xxx newimage.gif'
                sys.exit(0)

        if (len(sys.argv) > 4):
                # program width, height, image.xxx, 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
        sys.exit(0)
        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.
Help!






More information about the Python-list mailing list