Skip to content

Instantly share code, notes, and snippets.

@dchaplinsky
Last active August 29, 2015 14:10
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save dchaplinsky/d91e5f3dea13440d274d to your computer and use it in GitHub Desktop.
Save dchaplinsky/d91e5f3dea13440d274d to your computer and use it in GitHub Desktop.
Simple implementaiton of python's title that works well with ukrainian surnames and names (including compound ones and names with apostrophes)
# -*- coding: utf-8 -*-
from string import capwords
def title(s):
chunks = s.split()
chunks = map(lambda x: capwords(x, u"-"), chunks)
return u" ".join(chunks)
if __name__ == '__main__':
s = u"мар'яна семенюк-самсоненко"
print(title(s)) # Мар'яна Семенюк-Самсоненко
print(capwords(s)) # Мар'яна Семенюк-самсоненко
print(s.title()) # Мар'Яна Семенюк-Самсоненко
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment