Slicing vs .startswith

Shu-Hsien Sheu sheu at bu.edu
Mon Sep 22 17:17:53 CEST 2003


Hi,

I have a question about the comparison of efficiency of string slicing 
and using string.startswith.
For example, which one of the following would be more efficient, or , 
moreover, more pythonic?

if aa[:3] == 'abc':

vs

if aa.startswith('abc'):


Thanks!

-shuhsien






More information about the Python-list mailing list