| e_rsatz projects: ( @ 2005-08-19 14:57:00 |
| Entry tags: | python |
The Python I like - a bit of functional programming
To insert a white space before each uppercase letter within a string:
"".join([(i.isupper() and " "+i) or i for i in "PythonIsCool"])
or for the ones who like functional programming:
"".join(map(lambda x:(x.isupper() and " "+x) or x,"PythonIsCool"))
But I do personnally do like list comprehensions...