C++/Java class variables can be public, protected (accessible to class and 
subclasses) or private (accessible only to class). Of course the language 
protections can be hacked around.

Python does conceptual private variables by using the single underscore: 
object._myvar is considered private

From: Python-list <[email protected]> on 
behalf of Alan Gauld <[email protected]>
Date: Thursday, November 3, 2022 at 6:45 AM
To: Julieta Shem <[email protected]>, [email protected] 
<[email protected]>
Subject: Re: an oop question
*** Attention: This is an external email. Use caution responding, opening 
attachments or clicking on links. ***

On 03/11/2022 00:25, Julieta Shem wrote:

>> |OOP to me means only messaging, local retention and protection and
>> |hiding of state-process, and extreme late-binding of all things.
>
> I'm wondering how Python fails to satisfy his definition.

Python doesn't do any form of data protection/hiding. All
attributes are public by default.

In Smalltalk all attributes are private, with no way to
make them public... Actually in C++/Java terms I believe
they are "protected" because subclasses can access
them(I think?).

-- 
https://mail.python.org/mailman/listinfo/python-list

Reply via email to