Mutable strings
Andrew Dalke
adalke at mindspring.com
Tue Sep 23 00:54:01 EDT 2003
Rob Tillotson:
> There already is one: array. Mutable blocks of bytes (or shorts,
> longs, floats, etc.), usable in many places where you might otherwise
> use a string (struct.unpack, writing to a file, etc.).
Even regular expressions
>>> import array, re
>>> t = "When in the course of human events"
>>> s = array.array("c", t)
>>> pat = re.compile(r"([aeiou]{2,})")
>>> m = pat.search(s)
>>> m.group(1)
array('c', 'ou')
>>>
Andrew
dalke at dalkescientific.com
More information about the Python-list
mailing list