Newbie Q: Class Privacy (or lack of)

Ben Sizer kylotan at gmail.com
Fri Jul 28 05:28:53 EDT 2006


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!

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.

-- 
Ben Sizer




More information about the Python-list mailing list