[Tutor] Input

Kent Johnson kent37 at tds.net
Wed Jan 16 03:47:34 CET 2008


Ricardo Aráoz wrote:

> _validChars = {
>                 'X' :
> 'abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ1234567890'
>                 , '9' : '1234567890'
>                 , '-' : '-1234567890'
>                 , 'A' :
> 'abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ'
>                 , '!' : 'ABCDEFGHIJKLMNOPQRSTUVWXYZ'}
> _validKeys = _validChars.keys()

<snip>
>         while maskChar not in _validKeys :

There is no need to make _validKeys, you can write
   while maskChar not in _validChars
which is actually more efficient, in general, because it is a hash table 
lookup instead of searching a list.

Kent


More information about the Tutor mailing list