startswith( prefix[, start[, end]]) Query
cjt22 at bath.ac.uk
cjt22 at bath.ac.uk
Thu Sep 6 10:09:12 EDT 2007
Hi
startswith( prefix[, start[, end]]) States:
Return True if string starts with the prefix, otherwise return False.
prefix can also be a tuple of suffixes to look for. However when I try
and add a tuple of suffixes I get the following error:
Type Error: expected a character buffer object
For example:
file = f.readlines()
for line in file:
if line.startswith(("abc","df"))
CODE
It would generate the above error
To overcome this problem, I am currently just joining individual
startswith methods
i.e. if line.startswith("if") or line.startswith("df")
but know there must be a way to define all my suffixes in one tuple.
Thanks in advance
More information about the Python-list
mailing list