On Thu, Aug 27, 2009 at 9:16 AM, Emanuele D'Arrigo <man...@gmail.com> wrote:
> Greetings everybody, > > let's say I have a Class C and I'd like to verify if it implements > Interface I. If I is available to me as a class object I can use > issubclass(C, I) and I can at least verify that I is a superclass of > C. There are a couple of issues with this approach however: > > 1) C might override not just I's methods code but also I's methods > signatures, effectively changing the interface. > 2) What if I is -not- available to me as the superclass of C but as a > description of the interface, i.e. as an IDL(*) file? > > Are there resources such as tools, recipes, documents or strategies > that could help me deal with these issues? I've already looked into > the ABC module and the zope.interface. I'm just fishing for more > things to look at. > > Manu > > (*) http://en.wikipedia.org/wiki/Interface_description_language Python's general philosophy is that it's Easier to Ask Forgiveness than Permission. Don't check the interface, just assume it's true and wrap the code block in a try/except in case it isn't. > > -- > http://mail.python.org/mailman/listinfo/python-list >
-- http://mail.python.org/mailman/listinfo/python-list