[Python-Dev] random.jumpback?
Skip Montanaro
skip@mojam.com (Skip Montanaro)
Tue, 13 Feb 2001 21:56:11 -0600 (CST)
I was adding __all__ to the random module and I noticed this very unpythonic
example in the module docstring:
>>> g = Random(42) # arbitrary
>>> g.random()
0.25420336316883324
>>> g.jumpahead(6953607871644L - 1) # move *back* one
>>> g.random()
0.25420336316883324
Presuming backing up the seed is a reasonable thing to do (I haven't got
much experience with random numbers), why doesn't the Random class have a
jumpback method instead of forcing the user to know the magic number to use
with jumpahead?
def jumpback(self, n):
return self.jumpahead(6953607871644L - n)
Skip