passed extra info to repl function
Marc Christiansen
tolot at solar-system.dynodns.net
Mon Oct 29 15:26:04 EST 2001
Michael P. Soulier <msoulier at nortelnetworks.com> wrote:
> I'm using Python 1.5.2, so I can't use nested scopes to get around this.
> I'd like replace to be able to access an instance variable of
> self.replacement_dict, so that all replacement dictionaries are unique to
> the class instance, but the scoping rules prevent replace from seeing the
> self reference.
Use a default argument, i.e.
change
def replace(match):
to
def replace(match, replacement_dict=self.replacement_dict):
(untested)
Then the global replacement_dict is not needed anymore.
HTH
Marc
More information about the Python-list
mailing list