UnboundLocalError

Camellia breakfastea at gmail.com
Thu Nov 9 15:37:55 CET 2006


hi all

why it generates an "UnboundLocalError" when I do the following:

<code>
...
def main():
    number = number()
    number_user = user_guess()
    while number_user != number:
        check_number(number = number, number_user = number_user)
        number_user = user_guess()

UnboundLocalError: local variable 'number' referenced before assignment
</code>

I found when I changed the number() to num() or whatever the issue
solved
but doesn't every function has its own namespace?
Can anyone please explain it to me?

Peace




More information about the Python-list mailing list