def ibin(n, bits=0, str=False):
 if (not str):
  try:
   bits = as_int(bits)
   return [(1 if (i == '1') else 0) for i in bin(n)[2:].rjust(bits, '0')]
  except ValueError:
   return variations(list(range(2)), n, repetition=True)
 else:
  try:
   bits = as_int(bits)
   return bin(n)[2:].rjust(bits, '0')
  except ValueError:
   return (bin(i)[2:].rjust(n, '0') for i in range((2 ** n)))

def ibin ( n , bits = 0 , str = False ) : if ( not str ) : try : bits = as_int ( bits ) return [ ( 1 if ( i == '1' ) else 0 ) for i in bin ( n ) [ 2 : ] . rjust ( bits , '0' ) ] except ValueError : return variations ( list ( range ( 2 ) ) , n , repetition = True ) else : try : bits = as_int ( bits ) return bin ( n ) [ 2 : ] . rjust ( bits , '0' ) except ValueError : return ( bin ( i ) [ 2 : ] . rjust ( n , '0' ) for i in range ( ( 2 ** n ) ) )
return a list of length bits corresponding to the binary value of n with small bits to the right .