[Tutor] Checking for Control Characters
Sheila King
sheila@thinkspot.net
Sun, 7 Apr 2002 22:13:41 -0700
On Mon, 8 Apr 2002 00:13:57 -0500, dman wrote:
<do stuff for bad data entry>
>
> I recommend using a regex instead of a linear search. It will
likely
> be faster, if the number of taboo characters increases or if you
check
> multiple passwords with the same python process (persistent cgi?).
Actually, I did have a script I worked with a short while ago, where
we had a version that used string methods, and then we changed it in
the next version to use regex. And we found the regex to be slower.
In Python, regex is not as fast as in Perl (I believe). If you have
some fairly comlicated searches to do, or a lot of searches, then it
may be worth the overhead, and regex may be more efficient. But for
something as simple as what I am doing, I believe the simple string
methods will be quicker.
I am not doing persistent cgi, nor do I expect the number of taboo
characters to increase, nor will I be checking multiple passwords.
Otherwise, I would look into the regex, as you suggest.
Thanks,
--
Sheila King
http://www.thinkspot.net/sheila/