On 03/23/10 23:38, Tim Chase wrote:
<cut>
Just in case you're okay with a regexp solution, you can use
>>> s = "\t\tabc def "
>>> import re
>>> r = re.compile(r'^(\s*)(.*?)(\s*)$')
>>> m = re.match(s)
>>> m.groups()
('\t\t', 'abc def', ' ')
>>> leading, text, trailing = m.groups()
<cut>
Ahhh regex, the hammer, Swiss Army Knife, cable tie, duct tape,
superglue and soldering iron, all wrapped in one*. Mastery of it will
enable you to drive the nails in your coffin at an incomparable speed. :-)
*Yes I was a sysadmin, why do you ask?
--
mph
--
http://mail.python.org/mailman/listinfo/python-list