Re: startswith( prefix[, start[, end]]) Query

2007-09-10 Thread Bruno Desthuilliers
Steve Holden a écrit : > Bruno Desthuilliers wrote: > >> Steve Holden a écrit : > > [...] > >>> >>> Probably not really necessary, though, and they do say that premature >>> optimization is the root of all evil ... >> >> >> I wouldn't call this one "premature" optimization, since it doesn't >>

Re: startswith( prefix[, start[, end]]) Query

2007-09-08 Thread rzed
Duncan Booth <[EMAIL PROTECTED]> wrote in news:[EMAIL PROTECTED]: I went through your example to get timings for my machine, and I ran into an issue I didn't expect. My bat file did the following 10 times in a row: (the command line wraps in this post) call timeit -s "s='abracadabra1'*1000;t='

Re: startswith( prefix[, start[, end]]) Query

2007-09-07 Thread Steve Holden
Bruno Desthuilliers wrote: > Steve Holden a écrit : [...] >> >> Probably not really necessary, though, and they do say that premature >> optimization is the root of all evil ... > > I wouldn't call this one "premature" optimization, since it doesn't > change the algorithm, doesn't introduce (muc

Re: startswith( prefix[, start[, end]]) Query

2007-09-07 Thread Duncan Booth
"Tim Williams" <[EMAIL PROTECTED]> wrote: > Isn't slicing still faster than startswith?As you mention timeit, > then you should probably add slicing to the pot too :) > Possibly, but there are so many other factors that affect the timing that writing it clearly should be your first choice.

Re: startswith( prefix[, start[, end]]) Query

2007-09-07 Thread Bruno Desthuilliers
Steve Holden a écrit : > TheFlyingDutchman wrote: >>> Else, you could as well write your own testing function: >>> >>> def str_starts_with(astring, *prefixes): >>>startswith = astring.startswith >>>for prefix in prefixes: >>> if startswith(prefix): >>>return true >>>return

Re: startswith( prefix[, start[, end]]) Query

2007-09-06 Thread Steve Holden
TheFlyingDutchman wrote: >> Else, you could as well write your own testing function: >> >> def str_starts_with(astring, *prefixes): >>startswith = astring.startswith >>for prefix in prefixes: >> if startswith(prefix): >>return true >>return false >> > > What is the reason

Re: startswith( prefix[, start[, end]]) Query

2007-09-06 Thread TheFlyingDutchman
> Else, you could as well write your own testing function: > > def str_starts_with(astring, *prefixes): >startswith = astring.startswith >for prefix in prefixes: > if startswith(prefix): >return true >return false > What is the reason for startswith = astring.startswith

Re: startswith( prefix[, start[, end]]) Query

2007-09-06 Thread Tim Williams
On 06/09/07, Bruno Desthuilliers <[EMAIL PROTECTED]> wrote: > > You may want to try with a regexp, but I'm not sure it's worth it (hint: > the timeit module is great for quick small benchmarks). > > Else, you could as well write your own testing function: > > def str_starts_with(astring, *prefixes)

Re: startswith( prefix[, start[, end]]) Query

2007-09-06 Thread Bruno Desthuilliers
[EMAIL PROTECTED] a écrit : > 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 E

Re: startswith( prefix[, start[, end]]) Query

2007-09-06 Thread [EMAIL PROTECTED]
On Sep 6, 7:09 am, [EMAIL PROTECTED] wrote: > 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 erro

Re: startswith( prefix[, start[, end]]) Query

2007-09-06 Thread Carsten Haese
On Thu, 2007-09-06 at 07:09 -0700, [EMAIL PROTECTED] wrote: > 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

Re: startswith( prefix[, start[, end]]) Query

2007-09-06 Thread Tim Golden
[EMAIL PROTECTED] wrote: > 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. That particular aspect of the functionality (the multiple prefixes in a tuple) was only

startswith( prefix[, start[, end]]) Query

2007-09-06 Thread cjt22
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