Mercurial Hosting > traffic-intelligence
changeset 742:fe71639f1ee7 dev
merge and added function to up-/lower-case strings
author | Nicolas Saunier <nicolas.saunier@polymtl.ca> |
---|---|
date | Fri, 28 Aug 2015 10:39:15 -0400 |
parents | 5b91b8d97cf3 |
children | 4b3518f6dd01 |
files | python/tests/utils.txt python/utils.py |
diffstat | 2 files changed, 12 insertions(+), 0 deletions(-) [+] |
line wrap: on
line diff
--- a/python/tests/utils.txt Fri Aug 28 10:38:08 2015 -0400 +++ b/python/tests/utils.txt Fri Aug 28 10:39:15 2015 -0400 @@ -1,6 +1,9 @@ >>> from utils import * >>> from moving import Point +>>> upperCaseFirstLetter('mmmm... donuts') +Mmmm... Donuts + >>> computeChi2([],[]) 0.0 >>> computeChi2(range(1,10),range(1,10))
--- a/python/utils.py Fri Aug 28 10:38:08 2015 -0400 +++ b/python/utils.py Fri Aug 28 10:39:15 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 #########################