[EMAIL PROTECTED] a écrit :
> OK, it's a scripting language.
For which definition of "scripting language" ?-)
>>>> def g():
> ... os.remove('tokeneizer.pyc')
> ... reload( tokeneizer )
> ... tokeneizer.tokenize('sample_decaf.d')
> ...
>
> 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?
Short answer : never !-)
Long answer:
First point: "global" really means "module level" - there's no
"application global" namespaces.
Second point: every name declared as the top-level is global - according
to the above definition. So there's no need to declare them as such. The
only place where you need the global statement is when you want to
rebind a module-level name from within a function. And it's in this
function that you need to declare the name as global.
FWIW, this is documented.
Last point: Python is not C, and it definitively doesn't have pointers.
Trying to write C in Python is a waste of time and an experiment in
frustration (just like trying to write language XXX in language YYY for
any distinct values of XXX and YYY).
HTH
--
http://mail.python.org/mailman/listinfo/python-list