[Tutor] capitalize() but only first letter

Erik Price eprice@ptc.com
Wed Feb 5 18:02:07 2003


I'm writing a Python script that generates a JavaBean getter method and 
setter method based on command line parameters (type and property name). 
  It works beautiful, except for one thing.  I'm using the capitalize() 
method of the Python String type, and although this does capitalize the 
first letter of the word, it lowercases all the rest of the letters.  I 
need to capitalize just the first letter and leave all the other letters 
in the word alone.

(1) Where can I read the source of the String type?  I'm using Python 
2.2.2 on Cygwin.

(2) What would be the best way to extract the first character from a 
string variable?



Thanks,

Erik