[Tutor] global
Cliff Wells
logiplex@qwest.net
Fri Aug 1 15:37:01 2003
On Fri, 2003-08-01 at 11:15, Jeff Shannon wrote:
> Kirk Bailey wrote:
> # Flags to control things
> A=0 # Anchor toggle flag
> B=0 # Bold toggle flag
> I=0 # Italic toggle flag
> U=0 # underscore toggle flag
Just a suggestion: rather than have a bunch of global variables, why
not put these in a dictionary and pass it around? That neatly solves
the globals problem and makes your program a bit tidier:
flags = {
'anchor': 0,
'bold': 0,
'italic': 0,
'underscore': 0,
}
def htmlize(thing, flags):
[...]
if exists(thing, "'''"):
if flags['bold']:
thing = string.replace(thing, "'''", "<B>")
else:
thing = string.replace(thing, "'''", "</B>"
flags['bold'] = not flags['bold']
[...]
Regards,
--
Cliff Wells, Software Engineer
Logiplex Corporation (www.logiplex.net)
(503) 978-6726 (800) 735-0555