Python 2.4.3 (#1, Oct 3 2006, 00:36:06) [GCC 4.1.1 (Gentoo 4.1.1-r1)] on linux2 Type "help", "copyright", "credits" or "license" for more information. >>> import random >>> random.randrange(1000000000000, -100000000000000000000, -200) 267471051174796896L Obviously, the result is not in the specified range; 1000000000000 < 267471051174796896, -100000000000000000000 < 267471051174796896 and (267471051174796896 - 1000000000000) % (-200) != 0. I'm using 2.3.5 and 2.4.3, and their behaviors are identical. I haven't checked about 2.5.
Logged In: YES user_id=341410 2.5 has the same behavior. One workaround (until it gets fixed) is to do the following... def myrandrange(start, stop, step): return start + random.randrange((stop-start)//step)*step random.randrange should change to do some variant of the above, given sane start, stop, step arguments.