global variables and local functions.

Carl Banks imbosol at
Thu Aug 29 05:49:07 CEST 2002

Micah Mayo wrote:
> UnboundLocalError: local variable 'mlistLen' referenced before assignment

You need to put the statement "global mlistLen" at the top of your
function.  When a variable is assigned to inside a function, Python
assumes it is a local variable everywhere in that function, unless you
declare it global.


More information about the Python-list mailing list