Btw at interview time this solution would not be acceptable, because you are using still a built-in language construct for looping.
Btw at interview time this solution would not be acceptable, because you are using still a built-in language construct for looping.
Rather than asking the interview candidate to use recursion for a problem that shouldn't be solved using recursion (unless in a language where recursion is the idiomatic iteration method), it would be better to ask about a problem that is best solved using recursion rather than printing "Hello world" -- perhaps something from Project Euler (http://projecteuler.net/).
Yes, there is chance that arbitrary objects can provide different semantics for __mul__. It would be true for any language.
How do you know the __mul__ operator overload for string is implemented with iteration?
It is not operator overloading in the strictest sense, but more of duck typing. In Python (and Ruby), operators are syntactic sugar for method calls on the first operand.
Operator overloading on the contrary suggests a function add(a, b) that reacts differently through polymorphism (i.e according to the types of its arguments).
The distinction is important as overloading and polymorphism simply do not exist in Ruby and Python, only overriding.
That... makes no sense, the code is not looping anywhere.
And if you could somehow disqualify this bit, then recursion most definitely wouldn't qualify.