Asun Friere afriere at yahoo.co.uk
Wed Aug 12 04:06:54 CEST 2009

On Aug 12, 10:54 am, James Stroud <jstr... at mbi.ucla.edu> wrote:

> I wrote the function to test hashability of arbitrary objects. My reason
> is that the built-in python (2.5) hashing is too permissive for some
> uses. A symptom of this permissiveness comes from the ability to
> successfully hash() arbitrary objects:

Arbitrary, or anonymous objects and some uses or some users?  I'm
can't see why anyone would expect different instance of a class to be
equivalent keys.

> The basis for the exception is that the two instances do not have the
> same hash() although conceptually they might seem equal to the
> unitiated.

Perhaps the best solution would be for the unitiated to correct their
misaprehensions?  If you don't understand that you are instantiating a
number of anonymous instances of a class you are missing something
very fundamental.

> Were I to re-design python, I'd throw an exception in this
> case because of the ill-defined behavior one might expect if a C()
> serves as a key for a dict.

Then you couldn't to this:

d = {C():1, C():2, C():3}
a,b,c = d.keys()

Anonymous instances are a GoodThing(tm) and they can usually be de-
anonymised if need be.

More information about the Python-list mailing list