Orlando Florida Python Tutor Needed

vbgunz vbgunz at gmail.com
Tue May 13 00:05:29 EDT 2008


> I know you're looking for "one-on-one" help, direction, and/or
> tutelage, but since you've not received an answer (yet), here's some
> general info...

> For Decorators, have a gander at:
>    http://www.ddj.com/web-development/184406073;jsessionid=QCNTPTSNXZP2W...
>    http://www.ibm.com/developerworks/linux/library/l-cpdecor.html

I found the first link to decorators a while back. I didn't think much
of it and said to myself, I'd find it again. My googlefu wasn't on my
side this time so I thank you for bringing it to my attention again.
Very very good article. Cleared up some confusion on decorators and I
am much better and sharper at them.

I think what makes the *idea* of a decorator so hard is how *simple*
it really is. From my learning them so far, I know for a fact, I've
encountered situations in which decorators would have saved me from
headache and grief. Now, an excellent piece of ammo for the arsenal.

Lets see if I could explain a decorator in my own words. a decorator
is just a pattern e.g., nothing magical about them except for the
syntactical sugar '@'. The @func sugar is nothing more than a hook
that embeds the following function into the @func first argument
(similar to self or cls) AND then Python *implicitly* reassigns the
original function name to that of the decorator which enclosed it.
From this point out it's pretty much a closure or the wider known
factory function but the real essence of a decorator that can make it
a better closure is how *unobtrusive* it is at modifying a function
*without* actually manually rewriting the original function. Also, the
decorator hook '@' reduces duplication and makes explicit the idea
that a function is to be *decorated*.

I may have some terminology wrong but think I am actually getting the
hang of decorators. very very useful indeed. I have some stuff working
without a hitch though still a bit foggy on passing *args, **etc.
Well, not that I plan on using them for everything but I've already
experienced cases in which I know a decorator would have saved my ass.
Am so glad I took the time out to learn them. I'll learn them again
tomorrow and go over all the links you provided to me.

Larry, thank you for the links, I really appreciate them. If you or
anyone have any tips or more links on some good articles regarding
them, I would surely enjoy seeing them.

Now, class methods. What is one powerful common use case for them?
What is one thing they can do in which could perhaps be the sole
reason for their existence?

heh. I'll get them too :)





More information about the Python-list mailing list