Ciao, Michele: On Thu, Sep 4, 2008 at 11:48 AM, Michele Petrazzo <[EMAIL PROTECTED]> wrote: > Hi all, I want to modify the method that set use for see if there is > already an object inside its obj-list. Something like this: > > class foo: pass > > bar1 = foo() > bar1.attr = 1 > > bar2 = foo() > bar2.attr = 1 > > set( (bar1, bar2), key=lambda o: o.attr) > > and, of course, set has only one value. > > It's possible? > > Thanks, > Michele > -- > http://mail.python.org/mailman/listinfo/python-list >
looking at the source, maybe you could create a subclass of Set redefining the __contains__ method? Regards Marco -- Marco Bizzarri http://notenotturne.blogspot.com/ http://iliveinpisa.blogspot.com/ -- http://mail.python.org/mailman/listinfo/python-list