Implementing class attribute access methods via pseudo-functi on o verloading.

Michael Hoffman m.h.3.9.1.without.dots.at.cam.ac.uk at example.com
Mon Oct 25 13:49:13 CEST 2004


Doran_Dermot at emc.com wrote:

> However, I wonder if people coming from the Java/C++ world prefer:
> theProblem.title( "The Title" )

Well I can only speak for myself, but I programmed in C++ before Python 
and I certainly don't prefer that. <wink> And I thought the Java 
convention was to have separate setTitle()/getTitle() accessor methods, 
so I'm not sure if anyone would be used to title().

I find the fact that Jython automatically translates:

print obj.attribute
obj.attribute = "foo"

into

print obj.getAttribute()
obj.setAttribute("foo")

to be a godsend.

> Obviously the first version is less typing! However, the second version
> might feel more natural to Java/C++ programmers.  Just an observation!

Well, you could just change the minimum amount of code/idioms to move 
from Java to Python, but then, why not just use Java?

<wink>
-- 
Michael Hoffman



More information about the Python-list mailing list