How do you add a custom method to a built-in python datatype? For example, I\'d like to implement one of the solutions from this question but be able to call it as follows:
You can't add methods to built-in classes. But what's wrong with using functions? strip_inner(s) is just fine and pythonic.
If you need polymorphism, then just use if isinstance(obj, type_) to determine what to do, or for something more extensible, use a generic function package, like PEAK-Rules.