Callback with Decorator or Parameter in Python?
<p>I'm designing an API. What's preferred using </p>

<pre><code>@event1
def event_callback():
     print "wooop"
</code></pre>

<p>or something like:</p>

<pre><code>def event_callback():
    print "wooop"


event1(callback=event_callback)
</code></pre>

<p>The two alternatives are entirely equivalent. Decorator syntax was introduced because particularly for long functions it was easy to miss the decoration call following the definition, so you should use a decorator.</p>

python callback