Op 17-03-16 om 01:31 schreef Chris Angelico:
> On Thu, Mar 17, 2016 at 11:19 AM, Steven D'Aprano <st...@pearwood.info> wrote:
>> On Thu, 17 Mar 2016 10:14 am, Chris Angelico wrote:
>>
>>> On Thu, Mar 17, 2016 at 5:31 AM, Antoon Pardon
>>> <antoon.par...@rece.vub.ac.be> wrote:
>>>> It can be yes. Look at decorators. They don't provide functionality
>>>> we wouldn't have without them.
>>> Really? Okay, try implementing this without decorators:
>> [...]
>>> @monkeypatch
>>> class Foo:
>> [...]
>>
>>
>> I think Antoon is referring to decorator *syntax*, not the concept of
>> decorators in general. Decorator syntax is just syntactic sugar for:
>>
>>
>> class Foo:
>>     ...
>>
>> Foo = monkeypatch(Foo)
>>
>> which has been valid all the way back to Python 1.0.
>>
> Yes... in theory. But try rewriting my example to avoid decorator
> syntax. It won't work, because of this line:
>
>     orig = globals()[cls.__name__]
>
> It depends on the decorator being run before the name actually gets
> bound - which means the previous class is available to the decorator.
> You can't do that without decorator syntax, or messing around with
> multiple names.

So? That is an implementation detail. With a new features, functionality
can now be accessible in a way it was not before the feature. It still doesn't
add new functionality, which in this case was just transferring methods from
one class to an other.


-- 
https://mail.python.org/mailman/listinfo/python-list

Reply via email to