Python Documentation (should be better?)

Steven Bethard steven.bethard at gmail.com
Wed May 11 18:29:45 EDT 2005


Bruno Desthuilliers wrote:
> Ivan Van Laningham a écrit :
> 
>> Hi All--
>> The Python docs are not ideal.  I can never remember, for instance,
>> where to find string methods (not methods in the string module, but
>> methods with ''),
> 
> 
>  >>> dir('')
> ['__add__', '__class__', '__contains__', '__delattr__', '__doc__', 
> '__eq__', '__ge__', '__getattribute__', '__getitem__', '__getnewargs__', 
> '__getslice__', '__gt__', '__hash__', '__init__', '__le__', '__len__', 
> '__lt__', '__mod__', '__mul__', '__ne__', '__new__', '__reduce__', 
> '__reduce_ex__', '__repr__', '__rmod__', '__rmul__', '__setattr__', 
> '__str__', 'capitalize', 'center', 'count', 'decode', 'encode', 
> 'endswith', 'expandtabs', 'find', 'index', 'isalnum', 'isalpha', 
> 'isdigit', 'islower', 'isspace', 'istitle', 'isupper', 'join', 'ljust', 
> 'lower', 'lstrip', 'replace', 'rfind', 'rindex', 'rjust', 'rstrip', 
> 'split', 'splitlines', 'startswith', 'strip', 'swapcase', 'title', 
> 'translate', 'upper', 'zfill']

Probably more useful:

py> help(str)
Help on class str in module __builtin__:

class str(basestring)
  |  str(object) -> string
  |
  |  Return a nice string representation of the object.
  |  If the argument is a string, the return value is the same object.
  |
...
  |
  |  capitalize(...)
  |      S.capitalize() -> string
  |
  |      Return a copy of the string S with only its first character
  |      capitalized.
  |
  |  center(...)
  |      S.center(width[, fillchar]) -> string
  |
  |      Return S centered in a string of length width. Padding is
  |      done using the specified fill character (default is a space)
  |
...
  |
  |  upper(...)
  |      S.upper() -> string
  |
  |      Return a copy of the string S converted to uppercase.
  |
  |  zfill(...)
  |      S.zfill(width) -> string
  |
  |      Pad a numeric string S with zeros on the left, to fill a field
  |      of the specified width.  The string S is never truncated.
...


STeVe



More information about the Python-list mailing list