string->list->string

Jeff Collins jcollins at endeavors.com
Tue Apr 24 00:35:45 EDT 2001


On Tue, Apr 24, 2001 at 12:03:27AM +0000, Courageous wrote:
> 
> So. I forget how to do this AGAIN. I know how to convert a string to a list:
> 
> mylist = str ("alpha")

This is still a string.  Try:

alist = map(None, "alpha")

To convert it back:

''.join(alist)


> 
> but I don't remember the shorthand for converting it back?
> 
> On another note, is there a module somewhere that knows how to
> strip an entire set of user-specified characters from a string, ala:
> 
> "a!b%c^".stripchars("!%^")

import re
c = re.compile("[!%^]")
c.sub('', "a!b%c^")


-- 
Jeffery D. Collins, Ph.D.
Sr. Software Developer
Endeavors Technology, Inc.
http://www.endeavors.com




More information about the Python-list mailing list