String functions: what's the difference?

2006-03-09 Thread Harro de Jong
(absolute beginner here, sorry if this seems basic) Section 7.10 of 'How to Think Like a Computer Scientist' contains this discussion of string.find and other string functions: (quote) We can use these constants and find to classify characters. For example, if find(lowercase, ch) returns a

Re: String functions: what's the difference?

2006-03-09 Thread Martin v. Löwis
Harro de Jong wrote: I've tried all three, but the function is so small (test a single letter) I can't measure the difference. I'm using time.time() to see how long it takes to execute the function. I could use a loop to increase execution time, but then I might be measuring mostly

Re: String functions: what's the difference?

2006-03-09 Thread gry
First, don't appologize for asking questions. You read, you thought, and you tested. That's more than many people on this list do. Bravo! One suggestion: when asking questions here it's a good idea to always briefly mention which version of python and what platform (linux, windows, etc) you're

Re: String functions: what's the difference?

2006-03-09 Thread Harro de Jong
gry@ll.mit.edu wrote: One suggestion: when asking questions here it's a good idea to always briefly mention which version of python and what platform (linux, windows, etc) you're using. Of course, forgot about that. It's Python 2.4.2 for Windows. For testing performance the timeit

Re: String functions: what's the difference?

2006-03-09 Thread Magnus Lycka
Harro de Jong wrote: Thanks for the pointer. I was using time.time(), which I now see isn't very accurate on Windows. time.clock() is more accurate on Windows (and much less so on Linux, where it also measures something completely different.) --