jeanmichel at sequans.com
Mon Nov 3 13:41:41 CET 2014
----- Original Message -----
> From: "Gregory Ewing" <greg.ewing at canterbury.ac.nz>
> Steven D'Aprano wrote:
> > Like all good Pythonistas, we hate Java and think that
> > getter/setter
> > methods are pointless. But come on, they're not *wrong*,
> What's wrong is the statement that getters and setters
> are necessary to allow the implementation to change
> without changing the interface. That's factually
> incorrect in regard to Python.
I'm not sure that is what the course was stating:
"The advantage of
following this practice is that the implementer of the class
definition (often someone other than the user of the class) may
restructure the organization of the data fields associated with the
object while avoiding the need to rewrite code that uses the class."
I agree with Steven on that one, while getters/setters are not the preferred way, they are not utterly wrong.
Python uses the descriptor protocol which is basically getters and setters. It's is just hidden by a strange decorator syntax.
-- IMPORTANT NOTICE:
The contents of this email and any attachments are confidential and may also be privileged. If you are not the intended recipient, please notify the sender immediately and do not disclose the contents to any other person, use it for any purpose, or store or copy the information in any medium. Thank you.
More information about the Python-list