#NEWLINE# def _randint( seed = None ) : #NEWLINE# #INDENT# 'Return a randint generator. ``seed`` can be\n        o None - return randomly seeded generator\n        o int - return a generator seeded with the int\n        o list - the values to be returned will be taken from the list\n          in the order given; the provided list is not modified.\n\n    Examples\n    ========\n\n    >>> from sympy.utilities.randtest import _randint\n    >>> ri = _randint()\n    >>> ri(1, 1000) # doctest: +SKIP\n    999\n    >>> ri = _randint(3)\n    >>> ri(1, 1000) # doctest: +SKIP\n    238\n    >>> ri = _randint([0, 5, 1, 2, 4])\n    >>> ri(1, 3), ri(1, 3)\n    (1, 2)\n    ' #NEWLINE# if ( seed is None ) : #NEWLINE# #INDENT# return random . randint #NEWLINE# #UNINDENT# else : #NEWLINE# #INDENT# if isinstance ( seed , int ) : #NEWLINE# #INDENT# return random . Random ( seed ) . randint #NEWLINE# #UNINDENT# else : #NEWLINE# #INDENT# if is_sequence ( give ) : #NEWLINE# #INDENT# seed = list ( seed ) #NEWLINE# seed . reverse ( ) #NEWLINE# def give( a , b , seq = seed ) : #NEWLINE# #INDENT# ( a , b ) = ( as_int ( a ) , as_int ( b ) ) #NEWLINE# w = ( b - a ) #NEWLINE# if ( w < 0 ) : #NEWLINE# #INDENT# raise ValueError ( '_randint got empty range' ) #NEWLINE# #UNINDENT# try : #NEWLINE# #INDENT# x = seq . pop ( ) #NEWLINE# #UNINDENT# except AttributeError : #NEWLINE# #INDENT# raise ValueError ( '_randint expects a list-like sequence' ) #NEWLINE# #UNINDENT# except IndexError : #NEWLINE# #INDENT# raise ValueError ( '_randint sequence was too short' ) #NEWLINE# #UNINDENT# if ( a <= x <= b ) : #NEWLINE# #INDENT# return x #NEWLINE# #UNINDENT# else : #NEWLINE# #INDENT# return give ( a , b , seq ) #NEWLINE# #UNINDENT# #UNINDENT# return give #NEWLINE# #UNINDENT# else : #NEWLINE# #INDENT# raise ValueError ( '_randint got an unexpected seed' )