CamelCase in Python
Example for versions
Python 2.6.5
The program uses Python standard library functions translate
and title
.
title
counts all non-letters as word delimiters, so no need to change them to spaces before calling title
.
non_letters = ''.join(c for c in map(chr, range(256)) if not c.isalpha())
def camel_case(s):
return s.title().translate(None, non_letters)
print camel_case(raw_input())
Comments
]]>blog comments powered by Disqus
]]>