#NEWLINE# def RANGE( value ) : #NEWLINE# #INDENT# 'Convert a single integer or range spec into a slice\n\n    ``n`` should become ``slice(n, n+1)``\n    ``n:`` should become ``slice(n, None)``\n    ``n:m`` should become ``slice(n, m)`` and ``m > n`` must hold\n    ' #NEWLINE# if ( ':' in value ) : #NEWLINE# #INDENT# ( start , stop ) = value . split ( ':' , 1 ) #NEWLINE# start = UINT ( start ) #NEWLINE# if stop . strip ( ) : #NEWLINE# #INDENT# stop = UINT ( stop ) #NEWLINE# if ( start >= stop ) : #NEWLINE# #INDENT# raise ValueError ( 'End must be larger than start' ) #NEWLINE# #UNINDENT# #UNINDENT# else : #NEWLINE# #INDENT# stop = None #NEWLINE# #UNINDENT# #UNINDENT# else : #NEWLINE# #INDENT# start = UINT ( value ) #NEWLINE# stop = ( start + 1 ) #NEWLINE# #UNINDENT# return slice ( start , stop )