an oop question

Weatherby,Gerard gweatherby at uchc.edu
Thu Nov 3 07:07:19 EDT 2022


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 <python-list-bounces+gweatherby=uchc.edu at python.org> on behalf of Alan Gauld <learn2program at gmail.com>
Date: Thursday, November 3, 2022 at 6:45 AM
To: Julieta Shem <jshem at yaxenu.org>, python-list at python.org <python-list at python.org>
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?).



More information about the Python-list mailing list