e_rsatz projects: ([info]e_rsatz) wrote,
@ 2005-08-19 14:57:00
Previous Entry  Add to memories!  Tell a Friend!  Next Entry
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...




Create an Account
Forgot your login or password?
Login w/ OpenID
English • Español • Deutsch • Русский…