Properties/Decorators [WAS: Can I reference 1 instance of an object by more names ? rephrase]

George Sakkis george.sakkis at gmail.com
Wed May 23 18:43:08 EDT 2007


On May 23, 6:22 pm, Wildemar Wildenburger <wilde... at freakmail.de>
wrote:
> Diez B. Roggisch wrote:
> > It is that very apply.
>
> > And apply takes a function as argument + additional arguments, and executes
> > that function, returning the result of that function-call. It was used
> > before the
>
> > f(*args, **kwargs)
>
> > notation was introduced.
>
> > Now what we have here is "value" as function, passed as single argument to
> > apply (because decorators are just callables), which will invoke "value"
> > with no arguments. The result of that operation is the property-object,
> > that thus is returned by apply. And in the end gets assigned to the name
> > value in the cpu_ports-class.
>
> Sooo clever :). But apply is deprecated ... can I do the same thing some
> other way?
>
> W

Yes; check out the following:

http://aspn.activestate.com/ASPN/Cookbook/Python/Recipe/502243
http://aspn.activestate.com/ASPN/Cookbook/Python/Recipe/205183
http://aspn.activestate.com/ASPN/Cookbook/Python/Recipe/410698

George




More information about the Python-list mailing list