September 2008
3 posts
5 tags
Discrete Event Simulation with Python Coroutines
I’m building a discrete event simulation tool in Python. When I found out that Python 2.5 supported coroutines, I was excited. The results were less than satisfying. First, a little background. Discrete Event Simulation Discrete event simulation is pretty easy. You need an event queue, an environment to act on, and actors to simulate. When an actor wants to do something, they place an...
Sep 13th
4 notes
3 tags
Static Initializers for Optional Arguments
I had an issue with Python recently. It turns out that optional arguments are initialized statically. What does that mean? Well, it means that having an optional argument initialized to the empty list for later manipulation is a bad idea. For example: class Foo: def __init__(self, dependencies = []): self.dependencies = dependencies if __name__ == "__main__": f1 = Foo() f2 = Foo() ...
Sep 12th
Python n00b
I just started programming in Python, and I got frustrated by some simple things. I decided to post some “helpful” samples here.
Sep 12th