Brian's answer (a custom function) is the correct and simplest thing to do in general.
But if you really wanted to define a numeric type with a (non-standard) '%' operator, like desk calculators do, so that 'X % Y' means X * Y / 100.0, then from Python 2.6 onwards you can redefine the mod() operator:
import numbers
class MyNumberClasswithPct(numbers.Real):
def __mod__(self,other):
"""Override the builtin % to give X * Y / 100.0 """
return (self * other)/ 100.0
# Gotta define the other 21 numeric methods...
def __mul__(self,other):
return self * other # ... which should invoke other.__rmul__(self)
#...
This could be dangerous if you ever use the '%' operator across a mixture of MyNumberClasswithPct with ordinary integers or floats.
What's also tedious about this code is you also have to define all the 21 other methods of an Integral or Real, to avoid the following annoying and obscure TypeError when you instantiate it
("Can't instantiate abstract class MyNumberClasswithPct with abstract methods __abs__, __add__, __div__, __eq__, __float__, __floordiv__, __le__, __lt__, __mul__, __neg__, __pos__, __pow__, __radd__, __rdiv__, __rfloordiv__, __rmod__, __rmul__, __rpow__, __rtruediv__, __truediv__, __trunc__")