UnboundLocalError

Camellia breakfastea at gmail.com
Sat Nov 11 04:57:14 EST 2006


Oh thank you for pointing that out Fredrik, you made the case more
clear:)

On Nov 11, 7:19 pm, Fredrik Lundh <fred... at pythonware.com> wrote:
> Camellia wrote:
> > Oh how can I thank you enough, you make my day:)
> > According to what you said I finally figure it out, it is the same as:
>
> > <code>
> > b = 1
> > def a():
> >     b = b #no good:)
> > </code>if you really want to modify a variable that lives outside the function,
> you can use the "global" directive:
>
> http://effbot.org/pyfaq/how-do-you-set-a-global-variable-in-a-functio...
>
>  > So in every day programming I should avoid using the same name for
>  > different types of objects because they will step on each other,
>  > right?
>
> if you want to distinguish between things, giving them distinct names is
> always a good idea.
> 
> </F>




More information about the Python-list mailing list