So I'm learning bits and pieces of python. Here's some code that just doesn't seem pythonic, and I'd like to improve it. I'm doing stochastic simulations with a Gillespie style approach, but if that doesn't mean anything to you, no worries. I'm trying to avoid some iterations and replace them with something like a list comprehension. The code will work, only I'm looking for a better way to do the same thing.
First I calculate a stopping time (
maxTime). Then I calculate the time of an event (and store it if it's less than
maxTime). Then the time of the next event (and store again). I repeat until I finally get an event happening after
import random maxTime = random.expovariate(1) L =  eventTime = random.expovariate(10) while eventTime<maxTime: L.append(eventTime) eventTime += random.expovariate(10)
Any cleaner way to write this code?