Container __get/set/delitem__? (was Re: [Zope3-dev] naming issues: id vs name, delObject vs ?)

Ken Manheimer klm@zope.com
Tue, 14 May 2002 16:58:11 -0400 (EDT)


On Tue, 14 May 2002, Jim Fulton wrote:


> So, to summarize, there's a proposal to rename some methods from
> IContainer:
> 
>     old             new
>     ------------    -------------------
>     objectIds       keys
>     objectValues    values
>     objectItems     items
>     getObject       __getitem__ and get
>     hasObject       has_key
>     objectCount     __len__
>     setObject       __setitem__
>     delObject       __delitem__
> 
> Pros:
> 
>   - More familiar. Less to remember.
>   - folder['foo'] is more readable than folder.getObject('foo')
> 
> Cons:
> 
>   - The change may cause too much confusion between containers and 
>     dictionaries or other mapping objects. Content containers are 
>     not dictionaries. They have more specific semantics and shouldn't be

I'm sorry i was distracted when the discussion was happening last week, or 
i would have spoken up sooner - i see no "Con" here.  +1 +1 +1 ( = +1, i 
know) on aspects of the dictionary interface for folders.

I may be weird (rhetorical device; raises a knowing smile in everyone:-),
but i have *never* gotten over the dissonance of ".objectIds()" /
".objectValues()" / ".objectItems()", etc, on Zope2 folders.  They were
mis-motivated.  Having similarly named methods helps those of us with
feeble memories remember how to do similar things with diverse objects,
*in so far as the objects are similar*.  It doesn't corrupt us into
mistaking the objects types for one another - just as "__init__",
"__repr__", and etc don't.

> Alternate proposal:

Please, get over these residual fears and correct the old mistake.  We 
have nothing to lose but our hard-to-remember method names!

-- 
Ken
klm@zope.com

  Yesterday is history, tomorrow is a mystery, today is a gift.
   -- Some stress management consultant on CBS This Morning