Idea: __all__ in classes?
johnroth at ameritech.net
Fri Jan 17 13:49:57 CET 2003
"Michael Hudson" <mwh at python.net> wrote in message
news:7h3el7cm2o5.fsf at pc150.maths.bris.ac.uk...
> mlh at furu.idi.ntnu.no (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
> > 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.
> 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