Thursday 2 December 2004 — This is nearly 20 years old. Be careful.
Phillip Eby gives a long list of ways that Python is not Java. Talking about some Python code written by Java developers:
the sad thing is that these poor folks worked much, much harder than they needed to, in order to produce much more code than they needed to write, that then performs much more slowly than the equivalent idiomatic Python would.
He then describes in detail ways that Java idioms aren’t right for Python. One he mentioned I wasn’t familiar with: the property built-in function, new in Python 2.2.
Comments
One interesting use is for proxying attributes in objects that act as facades for other objects.
For example:
class A(object):
def __init__(self):
self.b = B()
x = property(fget=lambda self: self.b.x)
y = 6
class B(object):
def __init__(self):
self.x = 5
>>> print A().x, A().y
5 6
Add a comment: