Mercurial Hosting > traffic-intelligence
changeset 745:3d0321abb564 dev
merged
author | Nicolas Saunier <nicolas.saunier@polymtl.ca> |
---|---|
date | Thu, 10 Sep 2015 15:49:13 -0400 |
parents | ed6ff2ec0aeb (current diff) 4b3518f6dd01 (diff) |
children | e7ff0f60fef8 d45ab817ee11 |
files | |
diffstat | 2 files changed, 17 insertions(+), 0 deletions(-) [+] |
line wrap: on
line diff
--- 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))
--- 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 #########################