Does Python really follow its philosophy of "Readability counts"?

Benjamin Kaplan benjamin.kaplan at case.edu
Wed Jan 14 08:16:52 EST 2009


On Wed, Jan 14, 2009 at 7:07 AM, Steven D'Aprano <
steve at remove-this-cybersource.com.au> wrote:

> On Wed, 14 Jan 2009 10:53:33 +0000, Marc 'BlackJack' Rintsch wrote:
>
> > On Wed, 14 Jan 2009 07:14:06 +0000, Steven D'Aprano wrote:
> >
> >> On Wed, 14 Jan 2009 15:25:38 +1000, James Mills wrote:
> >>
> >>> On Wed, Jan 14, 2009 at 3:11 PM, Russ P. <Russ.Paielli at gmail.com>
> >>> wrote: (...)
> >>>
> >>>>> Give me one use-case where you strictly require that members of an
> >>>>> object be private and their access enforced as such ?
> >>>>
> >>>> You're kidding, right? Think about a ten-million line program being
> >>>> developed by 100 developers.
> >>>
> >>> No I"m sorry this is not a valid use-case.
> >>
> >> Why not? Just saying it isn't doesn't make it not.
> >
> > Because "developer" means people who don't mess with implementation
> > details.  So they respect the leading underscore convention.  No use
> > case for enforced access restriction.
>
>
> O rly? *raise eyebrow*
>
> http://www.clausbrod.de/cgi-bin/view.pl/Blog/
> WebHome#DefinePrivatePublic20080413_This
>
> or http://snipurl.com/a0ujm
>
> Sometimes developers have to work around encapsulation in their own code:
> http://www.gamedev.net/community/forums/topic.asp?topic_id=386856
>
> Sometimes they do it just because they can:
>
> http://java-interview-faqs.blogspot.com/2008/08/hacking-by-reflection-
> accessing-private.html
> or http://snipurl.com/a0tox
>
> And try this:
>
> http://www.google.com/codesearch?q=%22%23define+private+public%22
>




I think you actually just proved his point- the access restrictions are
pointless. If there are ways to access private variables, then aren't they
just private by convention as well? The only difference with Python is that,
rather than going through the introspection (which Python does better than
Java anyway) to get the variables, all you have to do is type that leading
underscore. Either way, you know you're doing something you shouldn't.


--
Steven

>  --
> http://mail.python.org/mailman/listinfo/python-list
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.python.org/pipermail/python-list/attachments/20090114/b8586a03/attachment-0001.html>


More information about the Python-list mailing list