On Tue, Aug 23, 2005 at 10:46:36AM +0200, Wolfgang Lipp wrote: > one point i don't seem to understand right now is why it says in the > function definition:: > > if type(s) is str or type(s) is unicode: > ... > > instead of using ``isinstance()``.
I don't think isinstance() would be okay. That test is meant as an optimization to avoid calling __str__ on str and unicode instances. Subclasses should still have their __str__ method called otherwise they cannot override it. > the code as it stands means i have to remember that *in this special > case only* (when deriving from ``unicode``), i have to add a > ``__str__()`` method myself that simply returns ``self``. Ah, I see that unicode.__str__ returns a str instance. > then of course, one could change ``unicode.__str__()`` to return > ``self``, itself, which should work. but then, why so complicated? I think that may be the right fix. Neil _______________________________________________ Python-Dev mailing list Python-Dev@python.org http://mail.python.org/mailman/listinfo/python-dev Unsubscribe: http://mail.python.org/mailman/options/python-dev/archive%40mail-archive.com