local variable referenced before assignment

Arnaud Delobelle arnodel at googlemail.com
Thu Oct 25 05:23:03 EDT 2007


On Oct 25, 10:02 am, Pete Bartonly <n... at try.invalid> wrote:
> Quick question, probably quite a simple matter. Take the follow start of
> a method:
>
> def review(filesNeedingReview):
>
>      for item in filesNeedingReview:
>          (tightestOwner, logMsg) = item
>
>          if (logMsg != None):
>              for logInfo in logMsg.changed_paths:
>
> This generates the error:
>
>    UnboundLocalError: local variable 'logMsg' referenced before assignment

Check your indentation?
Seems to me that you might really have:

def review(...):
    for ...:
        ....
    if (logMsg...):
        ....

HTH

--
Arnaud





More information about the Python-list mailing list