faqts : Computers : Programming : Languages : Python : Common Problems : Strings

+ Search
Add Entry AlertManage Folder Edit Entry Add page to http://del.icio.us/
Did You Find This Entry Useful?

1 of 2 people (50%) answered Yes
Recently 0 of 1 people (0%) answered Yes

Entry

Is there any way to make a wrapper for a string object, like UserDict is a wrapper for the dict type?

Jun 27th, 2000 00:37
unknown unknown, Thomas Wouters


There is the UserString module in the 1.6 alphas, and it seems to be 
fairly portable. (It defines all methods that strings have in 1.6, 
whereas they have none in 1.5.2, but that shouldn't bother portability. 
You can't use them unless you use 1.6 strings as well, though, because 
those methods are defined in terms of string methods ;-)

You can get the UserString module by downloading a 1.6 alpha, or by 
grabbing a recent CVS tree, or by browsing the CVS three through 
sourceforge:

http://www.sourceforge.net/cvs/?group_id=5470

The module should at least show that it's *possible* to write a string
wrapper ;-) though without the 1.6 additions to strings & the 
__contains__ overloader it might not be that efficient.