Python Productivity over C++
Ken Seehof
kens at sightreader.com
Thu Jun 15 23:58:19 EDT 2000
Actually C++ doesn't have true access control either. Just insert before your
includes:
#define private public
. . . well, almost ;-)
Thomas Wouters wrote:
> On Thu, Jun 15, 2000 at 07:50:14PM +0200, Michal Vitecek wrote:
>
> [ access control ]
>
> > >Look at the big picture. Do encapsulation, access control and type
> > >strictness really make C++ really less error prone than python?
>
> > >I think not.
>
> > but what are the method names with '_' at the beginning in modules for?
> > aren't they there as a kind of hack to implement some way of access
> > control?
>
> No, they are a form of reducing namespace clutter and name-clashing.
>
> Variable names starting with a '_' do not get imported into the local
> namespace when you use 'from <module> import *'. They are accessible just
> fine, they just do not get bound to a *local* (to the 'from module import'
> statement) name.
>
> Class variables (including methods) starting with a double _ get 'mangled'
> to make them private -- so you can store 'class-related' data without the
> risk of a subclass accidentily shadowing it. The class-related data is still
> very accessible, it's perfectly valid to say 'self._BaseClass__private_data'
> or some such.
>
> --
> Thomas Wouters <thomas at xs4all.net>
>
> Hi! I'm a .signature virus! copy me into your .signature file to help me spread!
--
Ken Seehof
kens at sightreader.com
starship.python.net/crew/seehof
Hi! I'm a .signature virus! copy me into your .signature file to help me spread!
-------------- next part --------------
A non-text attachment was scrubbed...
Name: kens.vcf
Type: text/x-vcard
Size: 343 bytes
Desc: Card for Ken Seehof
URL: <http://mail.python.org/pipermail/python-list/attachments/20000615/c0e17f7c/attachment.vcf>
More information about the Python-list
mailing list