global variables in python

Ralf Bierig c00rb at
Fri Nov 17 16:44:37 CET 2000


When I run this script (here you see only the important part of it) I
get an error message, which says, that i use python_insert (in the
if-statement) before I defineing it. What I would like to do is checking
the global variable and before eventually resetting it.
How can say to python, that it should use the global version. And not
redefining the same variable in the function as a local variable??

#Global variables
python_insert = 0

def read_inputfile2():
    """ read_inputfile(): """
    """ Read all lines after the /* PYTHON INSERT OFF */ comment """
    python_insert = 1
    for line in input_file.readlines():
        if line == "/* PYTHON INSERT OFF */\n":
            python_insert = 0
        if python_insert == 0:


Ralf Bierig

More information about the Python-list mailing list