def twips(val, mult=0.05):
 try:
  return (float(val) * mult)
 except (ValueError, TypeError, AttributeError, KeyError):
  if (val and val.endswith(u'pt') and (mult == 0.05)):
   return twips(val[:(-2)], mult=1.0)

def twips ( val , mult = 0.05 ) : try : return ( float ( val ) * mult ) except ( ValueError , TypeError , AttributeError , KeyError ) : if ( val and val . endswith ( u'pt' ) and ( mult == 0.05 ) ) : return twips ( val [ : ( - 2 ) ] , mult = 1.0 )
parse val as either a pure number representing twentieths of a point or a number followed by the suffix pt .