On Jan 14, 11:47 pm, Richard Szopa <[EMAIL PROTECTED]> wrote:
> Could you tell me what are the pros and cons of the two approaches
> (i.e. writing a decorator function and a decorator descriptor class)?

I prefer to use a class for introspection sake, since
there is no way to get information about an inner function
in a closure, whereas your users can introspect classes
pretty well.

>             super_object = super(self.__class__, self)

Notice that using super(self.__class__, self) is a common
mistake: the pitfalls with inheritance were discussed
very recently in this same newsgroup, you should be
able to find the post. What you need is

super(class_where_the_method_is_defined, self)

which is in general different from

super(self.__class__, self)

There is no clean way to determine the current class
in Python < 3.0 (Python 3.0 does it automatically);
if you want to see a hackish way involving
bytecode tricks see
http://groups.google.com/group/comp.lang.python/browse_frm/thread/a6010c7494871bb1/62a2da68961caeb6?hl=en&lnk=gst&q=currentClass#62a2da68961caeb6

(and notice that this is really not recommended).

   Michele Simionato
-- 
http://mail.python.org/mailman/listinfo/python-list

Reply via email to