[Python-3000] hash as attribute/property

Greg Ewing greg.ewing at canterbury.ac.nz
Wed Apr 5 01:59:36 CEST 2006


Barry Warsaw wrote:
> Certainly "foo.get_something()" and
> "foo.set_something(thing)" are much better spelled "foo.something" and
> "foo.something = thing".

If you already have a get/set pair, that definitely
makes sense. If hash() had been spelled get_hash()
it might have made sense there too.

But it wasn't, and for a reason, I think -- it
implies performing a substantial computation
rather than just retrieving a pre-existing value
from somewhere. Even if it's cached, that's still
true, since the computation needs to be done the
first time it's called.

Another consideration is that if something is a
method, you can get a bound method from it. With
a property that's much harder, and may be impossible
depending on how the property is implemented.

--
Greg


More information about the Python-3000 mailing list