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

-- 
http://mail.python.org/mailman/listinfo/python-list

Reply via email to