Cameron Simpson, 30.04.2010 00:47:
Here's a function from a script I wrote to bulk edit a web site. I was
replacing OBJECT and EMBED nodes with modern versions:
def recurse(node):
global didmod
[...]
didmod=True
continue
recurse(O)
>
The calling end looks like this:
SOUP = BeautifulSoup(srctext)
didmod = False # icky global set by recurse()
recurse(SOUP)
if didmod:
srctext = str(SOUP)
If didmod becomes True we recompute srctext and resave the file (or save it
to a copy).
You should rethink your naming in the above code and remove the need for a
global variable.
Stefan
--
http://mail.python.org/mailman/listinfo/python-list