Newbie Q: Class Privacy (or lack of)

Ray ray_usenet at yahoo.com
Fri Jul 28 05:36:48 EDT 2006


Ben Sizer wrote:
> Ray wrote:
> > Actually Bruno,  don't you think that the notion of flexibility in
> > Python comes at the expense of "security" is simply due to the fact
> > that the syntax of "screw up" is exactly the same as the syntax of "I
> > mean it this way and I do want it"?
> >
> > Perhaps if we use a different syntax when we want to say "I really want
> > this", it'll be better (so Python can differentiate between a typo and
> > a conscious decision).
>
> Surely the very nature of a typo is that you don't know at the time of
> typing that you've done the wrong thing. Therefore it's impossible to
> signal to Python that you don't want what you've actually typed!

Exactly! So what I'm saying is that if the syntax of rebinding a method
*has* to be different then assignment, maybe it'll catch typos more
often. (Of course if you STILL make a typo error while using a
different syntax...)

> The only way statically-typed languages prevent these errors is
> typically by prohibiting the operation entirely. Since Python doesn't
> want to do that, you can't effectively prevent this type of error.
> Luckily, I find that they don't actually arise in practice, and I've
> spent orders of magnitude more time in C++ having to coerce objects
> from one type to another to comply with the static typing than I
> probably ever will spend debugging Python programs where a typo caused
> an error of this type.

Yeah, I fully agree. Even Java is heaven compared to C++.

> 
> -- 
> Ben Sizer




More information about the Python-list mailing list