call 'the following function' using decorators

castironpi at gmail.com castironpi at gmail.com
Wed Feb 13 03:55:54 CET 2008


On Feb 12, 12:10 pm, castiro... at gmail.com wrote:
> 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.- Hide quoted text -
>
> - Show quoted text -

And Link could do well to call itself Blank/FuncBlank/NextFunc/
something clever



More information about the Python-list mailing list