# HG changeset patch # User Nicolas Saunier # Date 1441914553 14400 # Node ID 3d0321abb564b1172bfeec47d1995d898c3bef8f # Parent ed6ff2ec0aeb938e7042b3d2d6c4d8175037eab4# Parent 4b3518f6dd015fd5ac11ffc69cb4055b2828b67a merged diff -r ed6ff2ec0aeb -r 3d0321abb564 python/tests/utils.txt --- a/python/tests/utils.txt Thu Sep 10 15:48:01 2015 -0400 +++ b/python/tests/utils.txt Thu Sep 10 15:49:13 2015 -0400 @@ -1,6 +1,14 @@ >>> from utils import * >>> from moving import Point +>>> upperCaseFirstLetter('mmmm... donuts') +'Mmmm... Donuts' +>>> s = upperCaseFirstLetter('much ado about nothing') +>>> s == 'Much Ado About Nothing' +True +>>> upperCaseFirstLetter(s) == s +True + >>> computeChi2([],[]) 0.0 >>> computeChi2(range(1,10),range(1,10)) diff -r ed6ff2ec0aeb -r 3d0321abb564 python/utils.py --- a/python/utils.py Thu Sep 10 15:48:01 2015 -0400 +++ b/python/utils.py Thu Sep 10 15:49:13 2015 -0400 @@ -13,6 +13,15 @@ datetimeFormat = "%Y-%m-%d %H:%M:%S" ######################### +# Strings +######################### + +def upperCaseFirstLetter(s): + words = s.split(' ') + lowerWords = [w[0].upper()+w[1:].lower() for w in words] + return ' '.join(lowerWords) + +######################### # Enumerations #########################