def find_unit(quantity):
 import sympy.physics.units as u
 rv = []
 if isinstance(quantity, str):
  rv = [i for i in dir(u) if (quantity in i)]
 else:
  units = quantity.as_coeff_Mul()[1]
  for i in dir(u):
   try:
    if (units == eval(('u.' + i)).as_coeff_Mul()[1]):
     rv.append(str(i))
   except Exception:
    pass
 return sorted(rv, key=len)

def find_unit ( quantity ) : import sympy . physics . units as u rv = [ ] if isinstance ( quantity , str ) : rv = [ i for i in dir ( u ) if ( quantity in i ) ] else : units = quantity . as_coeff_Mul ( ) [ 1 ] for i in dir ( u ) : try : if ( units == eval ( ( 'u.' + i ) ) . as_coeff_Mul ( ) [ 1 ] ) : rv . append ( str ( i ) ) except Exception : pass return sorted ( rv , key = len )
finds the unit with the given url in the course tree and returns the unit .