Simple Function Decorator Sample Snippet

M

Mark H Harris

hi folks, I've come up with a simple snippet that intends to explain the
concept of decorations without an article (for on app help), while being
succinct and concise, while not being overly complicated.

Does this work? I have another one coming for args, similar, if this
works... comments appreciated. thanks.
 
S

Steven D'Aprano

hi folks, I've come up with a simple snippet

I don't think that this idea is original to you :) I'm pretty sure many
people have come up with the idea of a decorator that just announces when
it runs and when it is called. I know I have :)

People keep independently inventing this because it's an obvious, and
easy to understand, example. Nicely done.

that intends to explain the
concept of decorations without an article (for on app help), while being
succinct and concise, while not being overly complicated.

Does this work? I have another one coming for args, similar, if this
works... comments appreciated. thanks.

I tried to run your code, but every line is quoted with a > which causes
a syntax error. Was there a reason you quoted the snippet?
 
M

Mark H Harris

I don't think that this idea is original to you :) I'm pretty sure many
people have come up with the idea of a decorator that just announces when
it runs and when it is called. I know I have :)

oh, absolutely... every piece of that thing comes from somebody
(about six somebodies to be exact) what makes it unique is that its
compressed, in the right order (I think), and 'without' extraneous
gibberish that confuses the whole dang thing.
People keep independently inventing this because it's an obvious, and
easy to understand, example. Nicely done.

Its obvious until you get to the @charater. In fact its taken so
obviously by *everyone* that no one actually gets it explained without
eight pages or twelve steps of something until its all confused.

I tried to run your code, but every line is quoted with a > which causes
a syntax error. Was there a reason you quoted the snippet?

Yes, because depending on your interface the code can get mangled (the
indentation thing breaks). the quoted paste seems to avoid this mostly
with the downside that the quote characters need to be striped from the
py file. <sorry> by the way, any suggestions are welcome regarding
that too... there doesn't really seem to be a good way to share code on
the group consistently.

marcus
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,769
Messages
2,569,578
Members
45,052
Latest member
LucyCarper

Latest Threads

Top