OOP techniques in Python

Panos Laganakos panos.laganakos at gmail.com
Thu Apr 27 13:16:30 EDT 2006


I've been thinking if there's a point in applying some specific OOP
techniques in Python as we do in other languages.

i.e. we usually define private properties and provide public functions
to access them, in the form of:
get { ... } set { ... }

Should we do the same in Python:

self.__privateAttr = 'some val'

def getPrivateAttr(self):
    return self.__privateAttr

Or there's no point in doing so?

Some other techniques come to mind, but I think that Python tends to
allow the programmer to access stuff he wants even though he shouldn't
or in the form of a dict or list, rather than a method to do so.




More information about the Python-list mailing list