Dumb newbie back in shell
Marc 'BlackJack' Rintsch
bj_666 at gmx.net
Mon Dec 10 11:59:53 EST 2007
On Mon, 10 Dec 2007 08:31:01 -0800, MartinRinehart wrote:
> But that gets me to:
>
> ... line 110, in get_toks
> UnboundLocalError: local variable 'line_ptr' referenced before
> assignment
>
> Here's a bit of the code, with line #s
>
> ...
> 68 global line_ptr
> 69 global char_ptr
> ...
> 75 line_ptr = 0
> 76 char_ptr = 0
> ...
> 109 def get_toks( text ):
> 110 while line_ptr < last_line:
> ...
> So when is a global var global?
When you declare it ``global`` *in the function*. ``global`` on module
level has no effect. IMHO that should emit at least a warning…
Ciao,
Marc 'BlackJack' Rintsch
More information about the Python-list
mailing list