0
random.sample(xrange(lb), it)

when lb is larger it throws

OverflowError: Python int too large to convert to C long

since xrange does need that in Python 2.7!

Is there a workout around to this?

I tried from a different post this:

import itertools
xrange = lambda stop: iter(itertools.count().next, stop)

But random doesn't like that:

TypeError: object of type 'callable-iterator' has no len()

user4555363
  • 217
  • 1
  • 2
  • 8
  • possible duplicate of [\`xrange(2\*\*100)\` -> OverflowError: long int too large to convert to int](http://stackoverflow.com/questions/1482480/xrange2100-overflowerror-long-int-too-large-to-convert-to-int) – alexh Feb 19 '15 at 02:23
  • no duplicate none of the solution work – user4555363 Feb 19 '15 at 02:44
  • but i think random is the problem. but in the doc nothing is written about a upper bound. – user4555363 Feb 19 '15 at 02:47
  • Please tell us which solutions you have tried, and show us the errors they give you when they fail. – Kevin Feb 19 '15 at 04:06
  • possible duplicate of [Sample k random permutations without replacement in O(N)](http://stackoverflow.com/questions/10232338/sample-k-random-permutations-without-replacement-in-on) – Lesmana Feb 19 '15 at 11:46

0 Answers0