Vinay Sajip wrote: > You're right to be nervous: it's not hard to mangle subtypes. > >>>> class mystr(str): pass > ... >>>> s = mystr("Abc") >>>> s > 'Abc' >>>> type(s) > <class '__main__.mystr'> >>>> s2 = s.replace("A", "a") >>>> s2 > 'abc' >>>> type(s2) > <type 'str'> It's also difficult for the subclass to prevent this without creating an infinite loop... (I only spent about 10 minutes looking into it the other day, but that's what happened in all of my naive attempts at doing it in pure Python code). Cheers, Nick. -- Nick Coghlan | ncoghlan at gmail.com | Brisbane, Australia ---------------------------------------------------------------
RetroSearch is an open source project built by @garambo | Open a GitHub Issue
Search and Browse the WWW like it's 1997 | Search results from DuckDuckGo
HTML:
3.2
| Encoding:
UTF-8
| Version:
0.7.4