"Ethan Kennerly" <[EMAIL PROTECTED]> writes:

> I really like properties for readonly attributes,

Python doesn't have "readonly attributes", and to attempt to use
properties for that purpose will only lead to confusion.

> and their ability to make the interface more elegant, by hiding
> uninteresting methods (like dumb get/set accessors).

The best solution to this is not to create get/set accessors at
all. Just define a simple data attribute, name the attribute
logically, and use it normally. When the interface demands something
other than a plain attribute, *then* consider changing it to a
property; but prefer a plain data attribute in the usual case.

> >>> class a_class:

Define your classes as inheriting from 'object', or some other type in
the Python type hierarchy, and properties will work as expected.

    class a_class(object):
        # foo

-- 
 \          "When I get real bored, I like to drive downtown and get a |
  `\         great parking spot, then sit in my car and count how many |
_o__)                 people ask me if I'm leaving."  -- Steven Wright |
Ben Finney
-- 
http://mail.python.org/mailman/listinfo/python-list

Reply via email to