Movatterモバイル変換


[0]ホーム

URL:


[Python-Dev] Revised PEP 349: Allow str() to return unicodestrings

Wolfgang Lippparagate at gmx.net
Tue Aug 23 17:45:27 CEST 2005


i have to revise my last posting -- exporting the new ``str``pure-python implementation breaks -- of course! -- as soonas ``isinstance(x,str)`` [sic] is used. right now it breaksbecause you can't have a function as the second argument of``isinstance()``, but even if that could be avoided by cannyprogramming, the fact remains that any object derived frome.g. a string literal will still be constructed from theunderlying implementation and can't therefore be an instanceof the old ``str``. also, ``str.__bases__`` is not extendable(it's a tuple) and not replaceable (it's a built-in), so thereseems to be no way to get near a truly working solution exceptwith C-level patches.On Tue, 23 Aug 2005 17:21:57 +0200, Neil Schemenauer <nas at arctrix.com>  wrote:> 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.makes perfect sense, i'll change the line back._wolf


More information about the Python-Devmailing list

[8]ページ先頭

©2009-2025 Movatter.jp