At 04:52 PM 11/30/2007 +0000, Paul Moore wrote: >On 30/11/2007, Barry Warsaw <[EMAIL PROTECTED]> wrote: > > >> class Example: > > >> implements(IExample) > > > > This frame hacking is also a pretty common feature of other types of > > systems, such as ORMs. It can make certain Python code much more > > readable, so "frame hacking" is clearly a useful feature, at least it > > seems, in the context of a class definition. Is there a way to > > promote this to an API that's more principled than the sys._getframe > > () hack, and thus more acceptable to Guido and more portable to other > > implementations? > > > > (Or is something like this already in Py3K, and I just haven't > > noticed it yet? ;). > >There's class decorators: > > @implements(IExample) > class Example: > pass > >which could provide the same result in effect, but (as J-P points out) >it's still an API change and so not a direct replacement. IIRC, one of >the arguments for class decorators was that they are a way to avoid >the need for some of this getframe hacking, though.
Well, for what class-level frame hacking is typically used for, it would suffice to have a convenient way to refer to the local namespace, e.g. if you could do something like: implements(@, IExample) where @ was a shortcut for locals(). The most-used frame hacks (in zope.interface and most PEAK tools) just want to access the namespace of the current class definition, and maybe decorate the class in some way. _______________________________________________ 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