def ispower2(n):
 bin_n = binary_repr(n)[1:]
 if (u'1' in bin_n):
  return 0
 else:
  return len(bin_n)

def ispower2 ( n ) : bin_n = binary_repr ( n ) [ 1 : ] if ( u'1' in bin_n ) : return 0 else : return len ( bin_n )
returns the log base 2 of *n* if *n* is a power of 2 .