Idea: __all__ in classes?

John Roth johnroth at
Fri Jan 17 13:49:57 CET 2003

"Michael Hudson" <mwh at> wrote in message
news:7h3el7cm2o5.fsf at
> mlh at (Magnus Lie Hetland) writes:
> > I just had an idea: Perhaps the following could be a useful
> > for private attributes (and methods)?
> As a gut reaction, Heck No.  I'm a fan of cooperative encapsulation.
> [snip heresy <wink>]
> > With properties and metaclasses this should be fairly easy to
> > implement. (The private stuff I've already implemented with
> > a while back.)
> How do you distinguish access from inside the class and access
> outside?
> > Of course this need not be the default behaviour; a superclass with
> > a suitable __metaclass__ attribute would be sufficient...
> In which case ...
> > I guess my question is whether this seems like a good idea at all...
> > And if it, perhaps, should be proposed as a PEP for inclusion in the
> > standard libs or something?
> ... no.
> All IMHO, of course.
> Hmm, maybe pychecker could look for this sort of thing, though.  Or
> you could issue warnings on "inappropriate" accesses.  Strangely, I
> find that idea much more acceptable, and I'm not quite sure why.

Because there's already a convention for declaring a variable private:
begin the name with an underscore. I don't know if pyChecker looks
for this, but it certainly could.

John Roth
> Cheers,
> M.
> --
>   The bottom tier is what a certain class of wanker would call
>   "business objects" ...                      -- Greg Ward, 9 Dec 1999

More information about the Python-list mailing list