Deferring a function call
werner at thieprojects.ch
Tue Oct 19 20:38:43 CEST 2010
For me nothing beats using twisted ( http://www.twistedmatrix.com ) with
its clean implementation of deferreds and a host of other useful things
for simulations besides being the 'Swiss Army Knife' of networking in
Python. If you throw in stackless ( http://www.stackless.com )
simulations with extremely high counts of participants and/or fine
granularity distributed across multiple machines are fun to write,
operate and maintain.
On 10/18/10 6:21 PM, TomF wrote:
> I'm writing a simple simulator, and I want to schedule an action to
> occur at a later time. Basically, at some later point I want to call a
> function f(a, b, c). But the values of a, b and c are determined at the
> current time.
> One way way to do this is to keep a list of entries of the form [[TIME,
> FN, ARGS]...] and at simulated time TIME do: apply(FN, ARGS)
> Aside from the fact that apply is deprecated, it seems like there should
> be a cleaner (possibly more Pythonic) way to do this. Ideas?
More information about the Python-list