attributes, properties, and accessors -- philosophy
Lie Ryan
lie.1296 at gmail.com
Tue Nov 24 15:04:06 EST 2009
Ethan Furman wrote:
>
> Good tools to know about, and a consistent naming pattern also makes
> life easier (which I have since done ;).
>
> Let's head towards murkier waters (at least murkier to me -- hopefully
> they can be easily clarified): some of the attributes are read-only,
> such as record count; others are not directly exposed, but still
> settable, such as table version; and still others require a small amount
> of processing... at which point do I switch from simple attribute access
> to method access?
>
> ~Ethan~
method accessor is not pythonic, use property
property can be read-only, write-only (!), and it can process data
before returning and setting the real attributes.
More information about the Python-list
mailing list