I do like one-liners and do not like regexps!  That code puts mine to shame...  Thanks for the tip.  I'll use that one instead.<br><br><div class="gmail_quote">On Thu, May 8, 2008 at 7:40 PM, Dan Bishop <<a href="mailto:danb_83@yahoo.com">danb_83@yahoo.com</a>> wrote:<br>
<blockquote class="gmail_quote" style="border-left: 1px solid rgb(204, 204, 204); margin: 0pt 0pt 0pt 0.8ex; padding-left: 1ex;"><div><div></div><div class="Wj3C7c">> On Thu, May 8, 2008 at 9:12 PM, John Schroeder <<a href="mailto:jschr...@gmail.com">jschr...@gmail.com</a>> wrote:<br>

> > I have a string (which I got from the names of my classes) and I would like<br>
> > to print out my CamelCase classes as titles.<br>
><br>
> > I would like it to do this:<br>
><br>
> >>>> my_class_name = "ModeCommand"<br>
> > ## Do some magic here<br>
> >>>> my_class_name<br>
> > 'Mode Command'<br>
><br>
> > Anyone know any easy way to do this?  Thanks.<br>
<br>
</div></div><div class="Ih2E3d">On May 8, 9:04 pm, "Eric Wertman" <<a href="mailto:ewert...@gmail.com">ewert...@gmail.com</a>> wrote:<br>
> Something like this.  I'm sure there are other ways to do it.<br>
><br>
> import re<br>
><br>
> def addspace(m) :<br>
>         return ' ' + m.group(0)<br>
><br>
> strng = "ModeCommand"<br>
><br>
> newstr =  re.sub('[A-Z]',addspace,strng)<br>
><br>
> print newstr.strip()<br>
<br>
</div>Yes, there are other ways to do it.  If, for example, you like one-<br>
liners but not regexps:<br>
<br>
def add_spaces(text):<br>
    return text[:1] + ''.join((' ' + char if char.isupper() else char)<br>
for char in text[1:])<br>
<div><div></div><div class="Wj3C7c">--<br>
<a href="http://mail.python.org/mailman/listinfo/python-list" target="_blank">http://mail.python.org/mailman/listinfo/python-list</a><br>
</div></div></blockquote></div><br>