Colin J. Williams wrote: > The snippet of code below gives the result which follows > > for k in ut.keys(): > name= k.split('_') > print '\n1', name > if len(name) > 1: > name[0]= name[0] + name[1].capitalize() > print '2', name > name[0]= name[0].capitalize() > print '3', name > > 1 ['logical', 'or'] > 2 ['logicalOr', 'or'] > 3 ['Logicalor', 'or'] > > I was expecting that 3 would read ['LogicalOr', 'or']
str.capitalize() changes the first character to be uppercase and all later characters to be lower case. It does not leave the later characters alone. In [1]: str.capitalize? Type: method_descriptor Base Class: <type 'method_descriptor'> String Form: <method 'capitalize' of 'str' objects> Namespace: Python builtin Docstring: S.capitalize() -> string Return a copy of the string S with only its first character capitalized. -- Robert Kern [EMAIL PROTECTED] "In the fields of hell where the grass grows high Are the graves of dreams allowed to die." -- Richard Harter -- http://mail.python.org/mailman/listinfo/python-list