String Methods

Comments

  • String methods never modify the underlying string
  • Methods always return a new string (if applicable)
  • Sometimes, the methods look odd

Example

     t = ['Hello','World']
     
     # Old string module
     s = string.join(t,":")     # s = "Hello:World"
     
     # String method
     s = ":".join(t)            # s = "Hello:World"

The string module

  • Reimplemented to use string methods
  • Officially deprecated, but still in widespread use.
<<< O'Reilly OSCON 2001, New Features in Python 2, Slide 28
July 26, 2001, beazley@cs.uchicago.edu
>>>