Ad
  • Custom User Avatar

    I don't think this is a good idea, this looks like overengineering the problem.

    This will fail for all custom objects that implement a mul magic method, therefore supporting a multiply operation. @Voile has mentioned Fractions and Decimals, but string types can also be multiplied too.

    Secondly, if there is a problem with one of the arguments, Python will throw a very nice and informative TypeError exception. You don't need to wrap it in two nested if-statements.

    Thirdly, a failed isinstance() comparison will return False which will potentially hide an error and lead to unforeseen things.

    I see what you tried to do, but remember that simple is better than complex ;)