[Tutor] Object, methods, class

Alan Gauld alan.gauld at btinternet.com
Sun Feb 27 02:18:22 CET 2011


"Christopher Brookes" <chris.klaitos at gmail.com> wrote

> Is there in Python private/protected attributes in class like in 
> other
> langage ?

Steven has given you a comprehensive answer but as a bit of
history none of the early OOP languages used public/protected/private
etc. They either made all variables private (Smalltalk) or public
(Object Pascal and Simula(I think) ).

It was really C++ that started the vogue for mixing and matching
the styles. Even it didn't introduce protected until version 1.2 of
the language and Stroustrup admits to having concerns and
doubts about the wisdom of the decision. But several other
languages (Java, Object Pascal(aka Delphi) ) have followed
C++ down that route.

Python just asks users to be sensible, it doesn't attempt
to protect(excuse the pun) them from themselves!

Just musing....

-- 
Alan Gauld
Author of the Learn to Program web site
http://www.alan-g.me.uk/





More information about the Tutor mailing list