Overriding variables used by base classes

Corey Lubin google_mail at aristoweb.net
Fri Nov 14 07:17:58 EST 2003


[original.py]
someGlobal=1

class Original:
    def foo(self):
        # Make use of someGlobal
[/original.py]

[tainted.py]
from original import *
someGlobal=2

class Tainted(Original):
    pass
[/tainted.py]

How might one make it such that Tainted.foo makes use of
tainted.someGlobal, rather than original.someGlobal? Must I use
eval/exec? Note that the point is that I don't want to have to
duplicate the definition of foo.

Corey




More information about the Python-list mailing list