From: Mike Stok Date: 2002-09-25T01:01:02+09:00 Subject: Re: Yet Another "Thickie" question / Random Range In article <46487A0D3619D511BF860000F6B99827D2C5DE@PRESGGS17>, Firestone, Mark - Technical Support wrote: > Anyone got a good algorythm laying around for the equivalent of random() in > python... > > as in Random(x..y) to get a random number in the range x..y If you're talking integers then this could be the basis for something: def random(r) # assume r is a range of integers first < last r.first + rand(r.last - r.first + (r.exclude_end? ? 0 : 1)) end (no error checking, but random(6 .. 10) # => an integer from 6, 7, 8, 9, 10 random(6 ... 10) # => an integer from 6, 7, 8, 9 seems reasonable to me. I don't know what python does...) Hope this helps, Mike -- mike@stok.co.uk | The "`Stok' disclaimers" apply. http://www.stok.co.uk/~mike/ | GPG PGP Key 1024D/059913DA mike@exegenix.com | Fingerprint 0570 71CD 6790 7C28 3D60 http://www.exegenix.com/ | 75D2 9EC4 C1C0 0599 13DA