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

Doran_Dermot at emc.com Doran_Dermot at emc.com
Mon Oct 25 08:03:48 EDT 2004


Hi Michael,

Maybe I should change that to read "I prefer:" and "However, the second
version feels more natural to myself" ;-)

Thanks for all the info and useful comments!  I've reviewed how properties
work and they do seem to do what I want in a very neat way (the __doc__
feature is also very useful).  

Now I've just got to convince myself that I like the format!

Cheers!!

-----Original Message-----
From: python-list-bounces+doran_dermot=emc.com at python.org
[mailto:python-list-bounces+doran_dermot=emc.com at python.org]On Behalf Of
Michael Hoffman
Sent: 25 October 2004 12:49
To: python-list at python.org
Subject: Re: Implementing class attribute access methods via
pseudo-functi on o verloading.


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
-- 
http://mail.python.org/mailman/listinfo/python-list



More information about the Python-list mailing list