global variables and local functions.

Micah Mayo astrophels at yahoo.com
Thu Aug 29 04:57:27 CEST 2002


Hey Guys - stumped again.

Basically here's what I'm trying to do:
<pseudocode>
list1 = []
list2 = []
global_int = 0

populateList():
	f = open(file)
	for l in f.readline():
		populateList1
		populateList2
		global_int += 1

moveFiles():
	for x in range (global_int):
		etc..
		etc..
  </psuedocode>

this is the error I get:

  File "./mf.py", line 102, in ?
     moveFiles()
   File "./mf.py", line 34, in moveFiles
     populateLists()
   File "./mf.py", line 27, in populateLists
     mlistLen += 1
UnboundLocalError: local variable 'mlistLen' referenced before assignment


It doesn't exactly work, which confuses me because I have global lists 
that are populated by the first, and hashed by the second. Why doesn't 
this work with the int type?

Thanks alot.
Micah




More information about the Python-list mailing list