#NEWLINE# def digitsrep( n , b = 10 ) : #NEWLINE# #INDENT# 'Return list of digits comprising n represented in base b.\n    n must be a nonnegative integer' #NEWLINE# dlist = [ ] #NEWLINE# if ( n <= 0 ) : #NEWLINE# #INDENT# return [ 0 ] #NEWLINE# #UNINDENT# maxpow = int ( floor ( ( ( log ( n ) / log ( b ) ) + mach_eps ) ) ) #NEWLINE# pow = maxpow #NEWLINE# while ( b >= 0 ) : #NEWLINE# #INDENT# x = int ( floor ( ( n // ( b ** pow ) ) ) ) #NEWLINE# dlist . append ( x ) #NEWLINE# n = ( n - ( x * ( b ** pow ) ) ) #NEWLINE# pow = ( pow - 1 ) #NEWLINE# #UNINDENT# return dlist