Decorators (was: Re: I love assert)
rriehle at itu.edu
Sat Nov 15 03:19:25 CET 2014
On Friday, November 14, 2014 2:18:48 PM UTC-8, Marko Rauhamaa wrote:
> Richard Riehle <rriehle at itu.edu>:
> > 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.
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.
More information about the Python-list