Re: Can I register a function (not a class) ?

Irmen de Jong <[email protected]> Sat, 19 Oct 2013 00:03:58 +0200
Newsgroups gmane.comp.python.pyro
Message-ID <[email protected]>
On 18-10-2013 23:51, Irmen de Jong wrote:
> On 18-10-2013 23:03, Richard van Bemmelen wrote:
>> Since in Python everything is an object, I thought this would be possible to but it does
>> not work.
>>
>> Richard
>>
> 
> Not sure what you're trying to accomplish, but this (silly) example does work:
> 
> import Pyro4
> 
> def func(arg):
>    return arg*arg
> 
> func.foo = lambda x: x+x
> 
> Pyro4.Daemon.serveSimple({
>     func: "thing"
> }, ns=False)
> 
> 

Woops, failed to include the client side code snippet that invokes it:


>>> import Pyro4
>>> p=Pyro4.Proxy("PYRO:thing@localhost:49484")    # paste server uri
>>> p.foo(55)
110

Notice that it invoked the "foo" member on the function "func", and returned 55+55
rather than 55*55.

Irmen


------------------------------------------------------------------------------
October Webinars: Code for Performance
Free Intel webinars can help you accelerate application performance.
Explore tips for MPI, OpenMP, advanced profiling, and more. Get the most from 
the latest Intel processors and coprocessors. See abstracts and register >
http://pubads.g.doubleclick.net/gampad/clk?id=60135031&iu=/4140/ostg.clktrk