overwrite set behavior

Michele Petrazzo michele.petrazzo at TOGLIunipex.it
Thu Sep 4 11:48:18 CEST 2008


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



More information about the Python-list mailing list