Accessors in Python (getters and setters)

riquito at gmail.com riquito at gmail.com
Fri Jul 14 07:19:29 EDT 2006


mystilleef ha scritto:

> Methods are used to perform actions. Data attributes usually aren't. We
> are on different planes.

You aren't thinking pythonic. You should not make any difference
between accessing an attribute and accessing a function. They both just
need to receive the right data to process (and the module doc must tell
you wich is it).
There is of course many python code wich doesn't use properties, but
that's up to the developer: everybody write the way they like. You
could also find code with both getter/setter AND properties.
well used properties make your code cleaner, but if you don't find
yourself confortable with them, just don't use them, but never forget
them.

Riccardo




More information about the Python-list mailing list