[Python-3000] callable()

Andrew Koenig ark-mlist at att.net
Mon Jul 24 23:27:30 CEST 2006


> In both cases, __hash__ is not idempotent, and is thus an abomination.

Why do you say it's not idempotent?  The first time you call it, either it
works or it doesn't.  If it doesn't work, then you shouldn't have called it
in the first place.  If it does work, all subsequent calls will return the
same result.

> Case
> 1 is a perverse programmer -- well known to be capable of abominations.

What is perverse about case 1?  I'm not being disingenuous here; I really
don't know.  I am assuming, of course, that the object in question never
changes the value of its component once constructed.

> Case 2 sounds like a made-up example... can you think of anything real
> which behaves this way? (For instance: the file type doesn't even though
> it might, and I presume this is intentional.)

I'll admit it's a little more far-fetched; that's why it's second on the
list.  But hypothetical or not, I think it serves to underscore the original
point, which is that it is entirely plausible for objects to have properties
that trigger side effects when used, and for which it may be useful to have
a way of asking about their presence without triggering the side effects.





More information about the Python-3000 mailing list