[sugar] Python Style Guide
Tue Nov 14 06:39:57 EST 2006
Marco Pesenti Gritti wrote:
>> For simple public data attributes, it is best to expose just the
>> attribute name, without complicated accessor/mutator methods
> I'm not sure I like this... It's quite unusual for non python coders.
> If we want to keep it we should probably elaborate more on it in the
Unusual, but definitely idiomatic Python; there's just no need for
getters/setters on simple public members. If you need to replace a
member with a function later, you can do so without breaking existing code.
> With this method, how do you find out which attributes are supported
> other than by reading the code? Is there a way to document them?
It depends whether it's a program or a human doing the finding. For
humans, you can insert a helpful docstring in the class explaining what
each member holds. Within a program, you can make use of introspection
to peek inside an object and discover its members.
Ivan Krsti? <krstic at solarsail.hcs.harvard.edu> | GPG: 0x147C722D
More information about the Sugar-devel