[Chicago] Get/Set/Accessors in Python?
Brian Curtin
brian at python.org
Wed Dec 5 17:15:48 CET 2012
On Wed, Dec 5, 2012 at 9:38 AM, Malcolm Newsome
<malcolm.newsome at gmail.com> wrote:
> Additionally, a separate, but perhaps related question is that I have not
> seen public/private classes in Python. How might this factor into the whole
> accessor scenario? (Or, am I trying to relate two topics that have nothing
> to do with each other?)
There's no notion of private classes, but you could create private
attributes on a class using a leading double underscore. I and most
others don't recommend doing this.
class MyClass:
def __private(self):
...
Python uses "name mangling" to hide the __private method, but nothing
is stopping you from unmangling the name and just calling mangled
names.
Check out this first paragraph for more information:
http://en.wikipedia.org/wiki/Python_syntax_and_semantics#Objects
More information about the Chicago
mailing list