problem with variable scoping
Michael Dingler
mdingler at mindless.com
Wed May 26 14:51:09 EDT 1999
It's...
an embarassing question. Yes folks, I'm writing my first
Python program (a text to HTML converter) and I have a
slight misunderstanding with the variable scoping...
Let me present some code fragments:
last_line_empty = 0
.
.
.
def process(line):
...
if last_line_empty:
pass
else:
print "<P>"
last_line_empty = 1
You see, I want to replace empty lines with paragraph symbols,
but if there is more than one, I want just one <p>-tag... If
I leave out the last statement (setting last_line_empty to one),
it works, but otherwise I get a 'name error' on the 'if' line.
As last_line_empty isn't a string it should be mutable, is my
grasp on some Python concepts that weak or do I just have a
'bad brain day'?
...Michael...
More information about the Python-list
mailing list