[Python-Dev] transitioning from % to {} formatting (original) (raw)
Nick Coghlan ncoghlan at gmail.com
Thu Oct 1 23:11:57 CEST 2009
- Previous message: [Python-Dev] transitioning from % to {} formatting
- Next message: [Python-Dev] transitioning from % to {} formatting
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]
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
- Previous message: [Python-Dev] transitioning from % to {} formatting
- Next message: [Python-Dev] transitioning from % to {} formatting
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]