initializing mutable class attributes

Dan Perl dperl at rogers.com
Fri Sep 3 00:45:33 EDT 2004


"Shalabh Chaturvedi" <shalabh at cafepy.com> wrote in message
news:mailman.2797.1094171693.5135.python-list at python.org...
    .........
> Seriously though, I think it's part of Python ideology to trust the
> programmer a little more. Notice no private or protected members.
> Keeping things explicit and not implicit such as in this case trains
> users very quickly. They'll remember to call the parent __init__, or
> figure out very quickly when it doesn't work (hopefully with useful
> error messages). If things were happening behind the scenes, users will
> have a hard time finding out what's going on when it does not work as
> expected. Or if they are power users and want to tweak something,
> they'll may have to burrow around quite a bit.
>
> That said, in cases it may actually be useful to do certain things
> automatically. After all, making life easier for the user is certainly a
> good thing. IMO, it's important to accomodate needs of all kinds of
> users, but not their fancies. From what I've seen, that seems to be the
> way Python itself is developed.

I think that what you're saying and what other people have been saying is
that this is an idiom and it's better to follow idioms in a language because
it helps people understand your code.  I agree with that and I guess I will
end up following this idiom.  In the end, it's a choice between coding for
the beginners or coding for the experienced.  In general, that's not an
obvious choice, but this seems to be quite a common idiom, so the ratio of
beginners who don't know it to people who do know it should be small.

Dan





More information about the Python-list mailing list