How to get/set class attributes in Python
deelan
ggg at zzz.it
Sun Jun 12 07:59:27 EDT 2005
Kalle Anke wrote:
> I'm coming to Python from other programming languages. I like to
> hide all attributes of a class and to only provide access to them
> via methods.
(...)
> Is this the "Pythonic" way of doing it or should I do it in a different
> way or do I have to use setX/getX (shudder)
the pythonic way is to use "property" (as others have already explained)
only when is *stricly necessary*. this may clarify things up:
"Python Is Not Java"
<http://dirtsimple.org/2004/12/python-is-not-java.html>
HTH.
--
deelan <http://www.deelan.com>
More information about the Python-list
mailing list