#NEWLINE# def title( value , failure_string = 'N/A' ) : #NEWLINE# #INDENT# '\n    Converts a string into titlecase.\n    \n    Lifted from Django.\n    ' #NEWLINE# try : #NEWLINE# #INDENT# value = value . lower ( ) #NEWLINE# t = re . sub ( "([a-z])'([A-Z])" , ( lambda m : m . group ( 0 ) . lower ( ) ) , value . title ( ) ) #NEWLINE# result = re . sub ( '\\d([A-Z])' , ( lambda m : m . group ( 0 ) . lower ( ) ) , t ) #NEWLINE# if ( not result ) : #NEWLINE# #INDENT# return result #NEWLINE# #UNINDENT# return result #NEWLINE# #UNINDENT# except : #NEWLINE# #INDENT# return failure_string