"Dotan Cohen" <[EMAIL PROTECTED]> wrote
Let's start from there. I need the startswith() function, but I do
not
know it's name. I search for "strings" and find this:
4. String Services
* 4.1 string -- Common string operations
o 4.1.3 String functions
Personally I rarely start with the documentation.
I'd start either with the >>> prompt and the help()
function or I may use dir() as in dir("") to get a list
of all the attributes - including methods - of an object.
If I don't undertand what dir/help tell me, or don't see
anything promising, then I will search the docs.
So here is my session looking for startwith...
help("")
dir("")
['__add__', '__class__', '__contains__', '__delattr__', '__doc__',
'__eq__', '__
ge__', '__getattribute__', '__getitem__', '__getnewargs__',
'__getslice__', '__g
t__', '__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', 'isdi
git', 'islower', 'isspace', 'istitle', 'isupper', 'join', 'ljust',
'lower', 'lst
rip', 'partition', 'replace', 'rfind', 'rindex', 'rjust',
'rpartition', 'rsplit'
, 'rstrip', 'split', 'splitlines', 'startswith', 'strip', 'swapcase',
'title', '
translate', 'upper', 'zfill']
help("".startswith)
Help on built-in function startswith:
startswith(...)
S.startswith(prefix[, start[, end]]) -> bool
Return True if S starts with the specified prefix, False
otherwise.
With optional start, test S beginning at that position.
With optional end, stop comparing S at that position.
prefix can also be a tuple of strings to try.
If I'd done help(str) instead of help("") in the first case
I'd have got the full help screen for string objects including
startswith..
Never forget the >>> prompt as a source of research.
HTH
--
Alan Gauld
Author of the Learn to Program web site
http://www.freenetpages.co.uk/hp/alan.gauld
_______________________________________________
Tutor maillist - [email protected]
http://mail.python.org/mailman/listinfo/tutor