Alex Martelli writes:
> You make a good point.  I do like being able to say foo.bar=baz rather
> than foo['bar']=baz in certain cases -- not so much to save 3 chars, but
> to avoid excessive punctuation; however, I don't really need this AND
> all of dict's power at the same time, so, I don't inherit from dict:-).

Yes.  Attribute syntax looks nicer, in particular one implements a sort
of private "variables collected in a dict" thing (e.g. SQL field names)
but still wants some dict functionality.

Another variant I thought of would be to prefix dict methods with '_'
(except those that already start with '__') and (if implemented as a
dict subtype) also override the original names with a "sorry, use
_<foo>" error method.

(Posting a bit sporatically currently, disappearing for a week again
now.)

-- 
Hallvard
-- 
http://mail.python.org/mailman/listinfo/python-list

Reply via email to