Decorators (was: Re: I love assert)

Richard Riehle rriehle at
Sat Nov 15 08:42:00 CET 2014


Thanks.  I have only been using Python for about four years, so there are
features I have only recently discovered.   Decorators are one of them.  So
far, I encounter other Python users who are also unfamiliar with them.
When I discovered them, I instantly saw how they could be valuable.

Richard Riehle, PhD
Core Faculty, ITU

On Fri, Nov 14, 2014 at 6:36 PM, Mayank Tripathi <oquanox at> wrote:

> Decorators were there in Python 2.4, released in 2005. Not exactly new.
> On Sat Nov 15 2014 at 7:51:11 AM Richard Riehle <rriehle at> wrote:
>> On Friday, November 14, 2014 2:18:48 PM UTC-8, Marko Rauhamaa wrote:
>> > Richard Riehle <rriehle at>:
>> >
>> > > I find that not a lot of Python user really appreciate the power of
>> > > decorators.
>> >
>> > Well, I don't.
>> >
>> > All it means is that I've never seen a use of decorators that has
>> > enhanced the code. Once I "see the light," I'll have no problem changing
>> > my view.
>> >
>> >
>> > Marko
>> Decorators are new in Python, so there are not a lot of people using
>> them.  From my experience with other languages, especially Ada and Eiffel,
>> I enjoy the benefit of assertions (as pre-conditions and post-conditions
>> and invariants) at the specification level (not embedded in the code), so
>> decorators are closer to my other experience.   They bring me closer to the
>> Design by Contract model of Ada and Eiffel.   That is why I was so pleased
>> to see them added to Python.
>> It is true, however, that they are not immediately intutive in Python,
>> but once understood, they are handy IMHO for improving code reliability.
>>  Perhaps I was spoiled by having this capability in some other languages.
>> --
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <>

More information about the Python-list mailing list