OO in Python? ^^

Matthias Kaeppler void at void.com
Sun Dec 11 11:05:16 EST 2005


gene tani wrote:
> http://naeblis.cx/rtomayko/2004/12/15/the-static-method-thing
> http://dirtsimple.org/2004/12/java-is-not-python-either.html
> http://dirtsimple.org/2004/12/python-is-not-java.html
> 
> http://idevnews.com/PrintVersion_CaseStudies.asp?Search3=web+services&Go2=Go&ID=118
> http://www.idevnews.com/PrintVersion_TipsTricks.asp?ID=107
> http://www.eros-os.org/pipermail/e-lang/2001-June/005337.html

First of all, thanks everybody for posting all these answers and links, 
much appreciated. What Bruce Eckel wrote about dynamic typing was quite 
convincing and reasonable.

I stumbled over this paragraph in "Python is not Java", can anyone 
elaborate on it:

"In Java, you have to use getters and setters because using public 
fields gives you no opportunity to go back and change your mind later to 
using getters and setters. So in Java, you might as well get the chore 
out of the way up front. In Python, this is silly, because you can start 
with a normal attribute and change your mind at any time, without 
affecting any clients of the class. So, don't write getters and setters."

Why would I want to use an attribute in Python, where I would use 
getters and setters in Java? I know that encapsulation is actually just 
a hack in Python (common, "hiding" an implementation detail by prefixing 
it with the classname so you can't access it by its name anymore? Gimme 
a break...), but is that a reason to only write white box classes? ^^

- Matthias





More information about the Python-list mailing list