PEP 292 describes simpler string substitutions, i.e. $-strings. PEP 320 says that this is going into Python 2.4. I've had some code laying around that implemented $-strings as a subclass of unicode instead of what PEP 292 describes as a new string method. The advantage to this approach is that the feature is provided with no language changes, or changes to the existing string classes.
I've cleaned up my code and posted a patch to SF. I've also checked in an updated PEP 292 that fits my implementation more closely. Please review the PEP and the patch:
The reference implementation in the patch adds a couple of extra things that aren't part of the PEP, but were discussed at Monday's sprint. Specifically:
- a top level package called 'stringlib' is added to the standard library.
- the dstring class implemented PEP 292 is available through stringlib.dstring
- some handy dict subclasses that work with the dstring class are also provided.
The idea was that some of the constants and functions we want to keep from the string module would go in the stringlib package. That's not essential to the PEP of course.
If this stuff is approved for Python 2.4, I'll add test cases and documentation.