UnboundLocalError: local variable referenced before assignment

Bruno Desthuilliers bruno.42.desthuilliers at websiteburo.invalid
Tue Jun 8 09:58:03 EDT 2010


ch1zra a écrit :
> On Jun 8, 10:59 am, Bryan <bryanjugglercryptograp... at yahoo.com> wrote:
>> Python doesn't have one global namespace. Each module (file) has its
>> own namespace, which is a Python dict, and 'global' means defined in
>> the containing module's dict. Put the import:
>>
>>   from reportlab.pdfgen import canvas
>>
>> in the mkTable.py file. That brings 'canvas' into the mkTable module's
>> namespace.
>>
> 
> thanx so much, it worked.
> I am getting some other problems now,

Yeps. One of them being rebinding mkTable.canvas on the first call to 
mkTable.mkTable...

Get rid of the 'global canvas' at the beginning of the mkTable.mkTable 
function, and rename your local var to something else than canvas.




More information about the Python-list mailing list