Hi list,
I've read three or four articles on creating decorators. I don't know why,
but the use of decorators makes sense, yet the creation of them isn't
clicking. I get the idea, but when it comes to precisely how to write
one--what goes where and gets returned/called when--it's just not making
complete sense.
To simplify things, what might be an example of a decorator that, say,
prints "decorated" before whatever string the decorated function prints?
That is:
@prependDecorated()
def printSomething(str):
print str
printSomething("Hello world.")
#result should be:
decoratedHello world.
My attempt would be:
def prependDecorated(f):
def prepend():
return "decorated"+f()
#something should go at this level too?
As I said, I've already read several sources on this. Are there any that
people find especially clear and helpful? Thanks for any links and/or
explanations.
--
Alex Hall
Automatic Distributors, IT department
[email protected]
_______________________________________________
Tutor maillist - [email protected]
To unsubscribe or change subscription options:
https://mail.python.org/mailman/listinfo/tutor