Help with String Manipulation

Doug Stanfield DOUGS at oceanic.com
Wed Jun 23 11:17:13 CEST 1999


> From: wtanksle at dolphin.openprojects.net on Tuesday, June 22, 1999 3:26 PM

> Whew!  Is there any reason to not use: ... ??

The opportunity to challenge with a reference that I consider a good read?

Actually, I was deliberately much more pedantic than you made me out to be.
Doing:
>>> testring = "This is an example"
>>> testlist = map (ord, testring)
>>> testlist
[84, 104, 105, 115, 32, 105, 115, 32, 97, 110, 32, 101, 120, 97, 109, 112,
108, 101]

I thought made it much more obvious that a transformation happened, where a
newbie might confuse:
>>> x = list("This is an example.")
>>> x
['T', 'h', 'i', 's', ' ', 'i', 's', ' ', 'a', 'n', ' ', 'e', 'x', 'a', 'm',
'p', 'l', 'e',
 '.']

as having not done anything.  I know I had that problem as a beginner and
was hoping this would somehow help illustrate mutable and immutable more
clearly.  YMMV.

-Doug-




More information about the Python-list mailing list