On Aug 25, 4:56 pm, Hussein B <[EMAIL PROTECTED]> wrote: > AFAIUY (understand you), what it is called a property in Java, it is > called an attribute in Python? > Why Python encourages direct access to object's attributes?
The simplest answer is "Because Python is not Java" :) Speaking of which, have you read the blog post of the same name? It might be useful given your Java background: http://dirtsimple.org/2004/12/python-is-not-java.html > aren't > setters/getters considered vital in OOP (encapsulation)? Not at all. They're definitely part of the mechanism that Java provides for encapsulation, sure. However, because Python provides a consistent interface for accessing attributes and properties, you don't need to define a property unless your code requires it. If all your getters & setters are doing is reading & writing to an attribute, then why not just r&w directly to the attribute? If you later need to add more complexity to that process, you can easily create a property without having to change how any other piece of code refers to that property, given it shares the same interface with attributes. -- http://mail.python.org/mailman/listinfo/python-list