Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
Groups > comp.lang.python > #80152 > unrolled thread
| Started by | Jean-Michel Pichavant <jeanmichel@sequans.com> |
|---|---|
| First post | 2014-11-03 13:41 +0100 |
| Last post | 2014-11-04 18:38 +1300 |
| Articles | 2 — 2 participants |
Back to article view | Back to comp.lang.python
Re: Classes Jean-Michel Pichavant <jeanmichel@sequans.com> - 2014-11-03 13:41 +0100
Re: Classes Gregory Ewing <greg.ewing@canterbury.ac.nz> - 2014-11-04 18:38 +1300
| From | Jean-Michel Pichavant <jeanmichel@sequans.com> |
|---|---|
| Date | 2014-11-03 13:41 +0100 |
| Subject | Re: Classes |
| Message-ID | <mailman.15427.1415018508.18130.python-list@python.org> |
----- Original Message ----- > From: "Gregory Ewing" <greg.ewing@canterbury.ac.nz> > Steven D'Aprano wrote: > > Like all good Pythonistas[1], 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. > > -- > Greg 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. JM -- 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.
[toc] | [next] | [standalone]
| From | Gregory Ewing <greg.ewing@canterbury.ac.nz> |
|---|---|
| Date | 2014-11-04 18:38 +1300 |
| Message-ID | <cbr72vFmdcjU1@mid.individual.net> |
| In reply to | #80152 |
Jean-Michel Pichavant wrote: > Python uses the descriptor protocol which is > basically getters and setters. It's is just hidden by a strange decorator > syntax. This is about the interface, not the implementation. "Getters and setters" in this context means designing the API of your class to have things like getFoo() and setFoo() in it. That's not just totally unnecessary in Python, it's counterproductive. It makes the API tedious to use for no benefit. -- Greg
[toc] | [prev] | [standalone]
Back to top | Article view | comp.lang.python
csiph-web