decorators

Paul McGuire ptmcg at austin.rr._bogus_.com
Wed Nov 8 17:51:45 EST 2006


"Carsten Haese" <carsten at uniqsys.com> wrote in message 
news:mailman.1938.1163022175.11739.python-list at python.org...
> If none of the examples make you say
> "wow, I could use this" and if you don't find yourself writing
> repetitive setup/teardown/housekeeping code, you can probably live quite
> comfortably without using decorators.
>

Amen!  Don't force yourself to learn decorators if you don't need them at 
the moment.  Wait until you start repeating the same code (lock/unlock, 
dbready/dbcommit, logstart/logend, etc.) around multiple functions, then go 
back and try applying a decorator to simplify the job.  Having a real use 
for them will make it much easier to "get".

I will say, though, that I found the memoizing decorator to be especially 
intriguing and eye-opening, and didn't realize I needed it until I saw it 
laid out in front of me.

-- Paul





More information about the Python-list mailing list