Experimentally, I have combined "mxProxy":http://www.lemburg.com/files/python/mxProxy.html with the interfaces package. This gives the ability to have run-time enforcement of interfaces. If the current implementation's 'test' module can import 'Proxy', then the module will run through a couple Proxy based interface tests. Here is an example usage:
import Interface import Proxy class _Foo: def aMethod(self): """ a Method """ def bMethod(self): """ b Method """ IFoo = Interface.impliedInterface(_Foo) class Foo: __implements__ = (IFoo,) def aMethod(self): return 'foo!' def bMethod(self): return 'bar!' def cMethod(self): return 'you should not be able to call this!' # first, create a 'factory' that accepts a class and a list of names # in the interface. FooFactory = Proxy.ProxyFactory(Foo, IFoo.names()) # now, instances of FooFactory will be protected: foo = FooFactory() foo.aMethod() # this will work foo.bMethod() # this will also work foo.cMethod() # this will raise a Proxy.AccessError