[Python-ideas] exclusively1, common, exclusively2 = set1 - set2, set1 & set2, set2 - set1
Paul Moore
p.f.moore at gmail.com
Mon Jul 8 10:31:59 CEST 2013
On 8 July 2013 09:24, Eric V. Smith <eric at trueblade.com> wrote:
> > I think it would be freaky and weird if I did this:
> >
> > some_set.venn_split(second_set, another_set)
> >
> > (for lack of a better name) and the value of some_set was ignored. Class
> > methods are okay for things like alternate constructors, but I don't
> > think they are appropriate here.
>
> set.venn_split(second_set, another_set)
>
> It's no more surprising than this code not using the values from d:
>
> >>> d = {'a':1, 'b':2}
> >>> d.fromkeys([3, 4, 5])
> {3: None, 4: None, 5: None}
>
> versus:
>
> >>> dict.fromkeys([3, 4, 5])
> {3: None, 4: None, 5: None}
Surely the point is that in s.venn_split(s1, s2) the *value* of s might be
ignored, but the *type* of s should be the type of the results? So
subclassing works "as expected" (for some value of the word "expected" :-))
Paul.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.python.org/pipermail/python-ideas/attachments/20130708/0c88dd0f/attachment.html>
More information about the Python-ideas
mailing list