Top-rated recipes tagged "call"http://code.activestate.com/recipes/tags/call/top/2016-05-01T13:11:05-07:00ActiveState Code RecipesFunction guards for Python 3 (Python)
2016-05-01T13:11:05-07:00Dmitry Dvoinikovhttp://code.activestate.com/recipes/users/2475216/http://code.activestate.com/recipes/580658-function-guards-for-python-3/
<p style="color: grey">
Python
recipe 580658
by <a href="/recipes/users/2475216/">Dmitry Dvoinikov</a>
(<a href="/recipes/tags/call/">call</a>, <a href="/recipes/tags/decorator/">decorator</a>, <a href="/recipes/tags/dispatch/">dispatch</a>, <a href="/recipes/tags/function/">function</a>, <a href="/recipes/tags/guard/">guard</a>).
</p>
<p>This module implements a function guard - facility to redirect the the call to one of several function implementations at run time based on the actual call arguments.</p>
<p>Wrap each of the identically named functions in a @guard decorator and provide a _when parameter with a default value set to guarding expression.</p>
<p>See samples at the top of the module.</p>
Parse call function for Py2.6 and Py2.7 (Python)
2009-02-28T20:13:15-08:00Jervis Whitleyhttp://code.activestate.com/recipes/users/4169341/http://code.activestate.com/recipes/576671-parse-call-function-for-py26-and-py27/
<p style="color: grey">
Python
recipe 576671
by <a href="/recipes/users/4169341/">Jervis Whitley</a>
(<a href="/recipes/tags/ast/">ast</a>, <a href="/recipes/tags/call/">call</a>, <a href="/recipes/tags/function/">function</a>, <a href="/recipes/tags/namedtuple/">namedtuple</a>, <a href="/recipes/tags/nodevisitor/">nodevisitor</a>, <a href="/recipes/tags/parsing/">parsing</a>).
Revision 14.
</p>
<p>In some cases it may be desirable to parse the string expression "f1(*args)"
and return some of the key features of the represented function-like call. </p>
<p>This recipe returns the key features in the form of a namedtuple. </p>
<p>e.g. (for the above)</p>
<pre class="prettyprint"><code>>>> explain("f1(*args)")
[ Call(func='f1', starargs='args') ]
</code></pre>
<p>The recipe will return a list of such namedtuples for <code>"f1(*args)\nf2(*args)"</code>
Note that while the passed string expression must evaluate to valid python syntax,
names needn't be declared in current scope.</p>
CallPipe: Call the methods of an object in a remote process (Python)
2008-09-17T17:33:36-07:00david decotignyhttp://code.activestate.com/recipes/users/4129454/http://code.activestate.com/recipes/576509-callpipe-call-the-methods-of-an-object-in-a-remote/
<p style="color: grey">
Python
recipe 576509
by <a href="/recipes/users/4129454/">david decotigny</a>
(<a href="/recipes/tags/call/">call</a>, <a href="/recipes/tags/multiprocessing/">multiprocessing</a>, <a href="/recipes/tags/pipe/">pipe</a>, <a href="/recipes/tags/processing/">processing</a>, <a href="/recipes/tags/remote/">remote</a>).
Revision 6.
</p>
<p>I am process A and I own object Obj. Now I decide to fork(): process B is born.</p>
<p>How do I do to make process B call the methods of A's object Obj (and not the methods of its own copy of Obj...) ?</p>
<p>This is what this module does: you create the "CallPipe" for Obj prior to fork()ing, and then process B can call any method of A's object Obj through it.</p>