(self, n, maxsize=1<<BPF)
return _floor(r * maxsize) % n
Return a random int in the range [0,n).  Returns 0 if n==0.

        The implementation does not use getrandbits, but only random.
Return a random int in the range [0,n).  Returns 0 if n==0.
Return a random int in the range [ 0 n ) . Returns 0 if n == 0 .
def _randbelow_without_getrandbits(self, n, maxsize=1<<BPF):
        """Return a random int in the range [0,n).  Returns 0 if n==0.

        The implementation does not use getrandbits, but only random.
        """

        random = self.random
        if n >= maxsize:
            _warn("Underlying random() generator does not supply \n"
                "enough bits to choose from a population range this large.\n"
                "To remove the range limitation, add a getrandbits() method.")
            return _floor(random() * n)
        if n == 0:
            return 0
        rem = maxsize % n
        limit = (maxsize - rem) / maxsize   # int(limit * maxsize) % n == 0
        r = random()
        while r >= limit:
            r = random()
        return _floor(r * maxsize) % n
def _randbelow_without_getrandbits ( self , n , maxsize = 1 << BPF ) : random = self . random if n >= maxsize : _warn ( "Underlying random() generator does not supply \n" "enough bits to choose from a population range this large.\n" "To remove the range limitation, add a getrandbits() method." ) return _floor ( random ( ) * n ) if n == 0 : return 0 rem = maxsize % n limit = ( maxsize - rem ) / maxsize # int(limit * maxsize) % n == 0 r = random ( ) while r >= limit : r = random ( ) return _floor ( r * maxsize ) % n