I had issues like this with street names. Luckily, the list of names that don't play well with str.title() is fairly small in my case so I made a dictionary of them.
This is the code I use for that, maybe you can get an idea (or, maybe even come up with a way to populate the dictionary with python (split at the ', title() the splits, then append them back together as titlecased or something).
Some extra code in here as this code also makes sure streets with N,S, etc. stay capitalized, and streets like 1st street aren't (1ST) (so that the upperWords and lowerWords makes sense).
def CalcStreetLabels():
fields = ['DirectPrefix', 'StreetName','StreetLabels']
upperWords = ["N","NW","W","SW","S","SE","E","NE","US","PR"]
lowerWords = ["1ST","2ND","3RD","4TH","5TH","6TH","7TH","8TH","9TH","10TH","11TH","12TH","13TH"]
subDict = {
"MCMURRAY ST": "McMurray St",
"MCMURRAY AVE": "McMurray Ave",
"MCINTOSH CT": "McIntosh Ct",
"MCEWAN DR": "McEwan Dr",
"MCPHERSON AVE": "McPherson Ave",
"MCCLELLAN ST": "McClellen St",
"BY-PASS": "Bypass Hwy SR 240",
"SR 240": "SR 240",
"O'CONNOR ST":"O'Connor St",
"MCMURRAY": "McMurray",
"MCINTOSH": "McIntosh",
"MCEWAN": "McEwan",
"MCPHERSON": "McPherson",
"MCCLELLAN": "McClellen",
"O'CONNOR":"O'Connor"
}
with arcpy.da.UpdateCursor(infc,fields) as uCur:
words = []
for row in uCur:
label = ""
if row[1]:
words =((' '.join(filter(None, [row[0], row[1]]))).split(" "))
for word in words:
if word in upperWords:
label += word.upper() + " "
elif word in lowerWords:
label += word.lower() + " "
else:
label += str(word).title() + " "
if subDict.has_key(row[1]):
label = subDict[row[1]]
row[2] = label
if label:
uCur.updateRow(row)
In case it helps any,
R_