Dirkjan Ochtman wrote:
> I don't know how hard it would be for Jython, IronPython et al. to 
> support this kind of interface, but seeing as how something like 
> zope.interface relies on it (and therefore all of Twisted, too, I 
> think), it's kind of mandatory anyway.

zope.interface could work without sys._getframe(). It's not mandatory
for its API. getframe is used for a clever hack which makes declaring
interfaces more convenient and readable.

class Example:
    implements(IExample)

The implements() function uses frame inspection to find and modify the
local namespace of the class. The code looks like:

def implements(...):
    frame = sys._getframe(...)
    locals = frame.f_locals
    locals['someinterfacedata'] = ...

The same class and interface definition could be written as:

class Example:
    pass

implements(Example, IExample)

but it's not as readable as the version of implements() with stack
inspection.

Christian

_______________________________________________
Python-3000 mailing list
Python-3000@python.org
http://mail.python.org/mailman/listinfo/python-3000
Unsubscribe: 
http://mail.python.org/mailman/options/python-3000/archive%40mail-archive.com

Reply via email to