A matter of style: class.foo = bar vs. class.set_foo(bar)

Syver Enstad syver.enstad at sensewave.com
Sat Nov 11 09:23:28 EST 2000


"Aahz Maruch" <aahz at panix.com> wrote in message
news:8uhkk9$2r5$1 at panix2.panix.com...
> Generally speaking, because Python does not have private parts, you only
> use a method when you want to trigger an action in addition to just
> changing the variable's value.
It does have a kind of privacy if you prefix your instance variables with
two underscores "__". Python will then mangle the name if used outside the
class so that it will be extremely painful to use it directly. The problem
then is using the variable from a derived class, it seems you'll have to use
accessors then too.





More information about the Python-list mailing list