global variables and local functions.

Dennis Lee Bieber wlfraed at ix.netcom.com
Thu Aug 29 13:19:38 EDT 2002


Micah Mayo fed this fish to the penguins on Wednesday 28 August 2002 
09:11 pm:

>
> okay,
> 
> sourcePath = []
> destPath = []
> mlistLen = 0
> 
> populateLists():

        I'm stale, and tend not to use globals if I can avoid them but...

        Try inserting:

        global mlistLen
        global sourcePath
        global destPath

at this location. I'm presuming your complaint is that mlistLen et al 
aren't updating.

>       textFile = open('movelist')
>       for eachLine in textFile.readlines():
>               source, dest = eachLine.split()
>               sourcePath.append(source)
>               destPath.append(dest)
>               mlistLen += 1
> 
> moveFiles():

        Also insert the global statements (syntax may allow comma separated 
list -- check the docs)

        Alternatively, forget about mlistLen totally and use 

        for x in range(len(sourcePath))
>       for x in range(mlistLen):
>               shutil.copy2(sourcePath[x],destPath[x])
>               
> So, that's the part that doesn't work almost line for line.
--
 > ============================================================== <
 >   wlfraed at ix.netcom.com  | Wulfraed  Dennis Lee Bieber  KD6MOG <
 >      wulfraed at dm.net     |       Bestiaria Support Staff       <
 > ============================================================== <
 >        Bestiaria Home Page: http://www.beastie.dm.net/         <
 >            Home Page: http://www.dm.net/~wulfraed/             <



More information about the Python-list mailing list