But in this function, I don't like the idea to try an
> operation on a string, and wait for an exception in order
> to know if we really have a string or not. It's not very
> efficient, nor very beautiful.
> I guess initial developer did that to keep compatibility
> with old Python versions.
I did it because it is general, elegant, and efficiency doesn't matter
here (any string operation is insignificant to the work we do making a
figure). What if a user writes their own string class, eg someone
wants a mutable string, or a lower case string, or any number of
custom string objects, and these aren't covered by the types module?
We make heavy use of duck typing in matplotlib, and it hasn't caused
us any problems I know of.