[Tutor] check against multiple variables

Emile van Sebille emile at fenx.com
Thu Jul 19 21:49:22 CEST 2012


On 7/19/2012 12:29 PM Selby Rowley-Cannon said...
> I am using a hash table in a small randomization program. I know that
> some hash functions can be prone to collisions, so I need a way to
> detect collisions.
> The 'hash value' will be stored as a variable. I do not want to check it
> against each singular hash value, as there will be many; I need a way to
> check it against all hash values at once (if possible.)

so keeping the hash values in a dict would allow you to test as follows:

if new_hash_value in dict_of_hash_values:
     # and bob's your uncle.

Emile


> Sorry for those
> who like to reference, but there is no source code as of yet. I will
> need this to be solved before I can start writing, sorry!
>
> If you need any extra info let me know.
>
>          -Selby
> _______________________________________________
> Tutor maillist  -  Tutor at python.org
> To unsubscribe or change subscription options:
> http://mail.python.org/mailman/listinfo/tutor
>





More information about the Tutor mailing list