[Tutor] Slightly OT: public/private class members

Gonçalo Rodrigues op73418@mail.telepac.pt
Fri Feb 14 09:37:02 2003


----- Original Message -----
From: "Jerry Jorgenson" <jerry@j3iss.com>
To: <tutor@python.org>
Sent: Friday, February 14, 2003 1:31 PM
Subject: Re: [Tutor] Slightly OT: public/private class members


> > So, what's the need/use for private members?
>
> Private members help avoid side effects. If you can't call a
> variable/class/data from outside the local scope, then you
> must act on it (them) with the defined methods, so bugs are
> (theoretically) easier to find and harder to create.
>
> On this subject, why can't Python enforce variable names ( e.g.
> use strict), and why are all variables global in scope. These
> to "features" are why I don't use Python much.

Uh? Variables declared within function scope are local to that scope and
cannot leak to the outside environment(*). Unless you explicitly declare
them as global, that is.

And what does strict (Perlicism?) do?

> Jerry
>

(*) Actually, I believe there are ways to get at them, but they are black &
evil as black & evil magic gets.

With my best regards,
G. Rodrigues