[Zope-CMF] Re: [CMF-checkins] CVS: CMF/CMFCore - ActionsTool.py:1.26

Shane Hathaway shane@zope.com
Sun, 10 Mar 2002 09:34:39 -0500 (EST)


On Sun, 10 Mar 2002, Chris Withers wrote:

> Shane Hathaway wrote:
> >
> > That sounds like it'll work, but it only removes a certain kind of
> > duplicates.  The code in that place was intended to be replaced with
> > something that really knew how to remove duplicates, but it's hard to
> > define "duplicate action" other than in the very narrow sense of
> > comparing by identity.
>
> ...or equality, they're only dictionaries at that point afterall ;-)
>
> > So that code is probably good but I'd hope to
> > see a different comment next to it, to the effect of "remove actions
> > that are obviously duplicated based on simple identity, but don't try to
> > remove all duplicates".
>
> See new comment ;-) I even provided an alternative bit of code, but it's slower
> & Python 2.1 specific, so I left the identity check in for now.

Hmm, I may have been misled...

Python 2.1.2 (#1, Mar  8 2002, 21:12:47)
[GCC 2.96 20000731 (Mandrake Linux 8.1 2.96-0.62mdk)] on linux2
Type "copyright", "credits" or "license" for more information.
>>> {'a':1} in ({'b':1}, {'a':1})
1
>>> {'a':2} in ({'b':1}, {'a':1})
0

"in" compares by equality.  Go figure. ;-)  Your list incomprehension
looks like it has the same effect as "in".

Still, what I had in mind was the removal of duplicates based only on the
name that shows up in the actions box, but that might not be what everyone
would want.

Shane