call 'the following function' using decorators
castironpi at gmail.com
castironpi at gmail.com
Tue Feb 12 13:10:55 EST 2008
On Feb 12, 12:05 pm, "Gabriel Genellina" <gagsl-... at yahoo.com.ar>
wrote:
> En Tue, 12 Feb 2008 15:20:32 -0200, <castiro... at gmail.com> escribi�:
>
>
>
>
>
> > I assert it's easier to write:
>
> > start_new_thread( this_func )
> > def thrA():
> > normal_suite()
>
> > than
>
> > def thrA():
> > normal_suite()
> > start_new_thread( thrA )
>
> > If you don't, stop reading. If you do, accomplish it like this:
>
> > @decwrap( start_new_thread, Link, ( 2, 3 ) )
> > def anonfunc( a, b ):
> > print( a, b )
>
> And I have to *guess* that start_new_thread is called?
> A @threaded decorator might be useful, but the above isn't clear at all.
>
> `import this` inside the interpreter.
>
> --
> Gabriel Genellina- Hide quoted text -
>
> - Show quoted text -
No new guessing. It's called in
ret= func( *ar2, **kwar2 )
You might suggest a better name, though, than decwrap. Something like
@call_here
with_specified_function. What? This probably goes under "Complex is
better than complicated."
It's not a typical decorator, but the f= g( f ) semantics come handily.
More information about the Python-list
mailing list