[Python-ideas] Re: Instance method to test equivalence between set and iterable

2020-03-24 Thread Steve Jorgensen
Steven D'Aprano wrote: > On Mon, Mar 23, 2020 at 12:03:50AM -, Steve Jorgensen wrote: > > Every set is a superset of itself and a subset of > > itself. A set may > > not be a "formal" subset or a "formal" superset of itself. issubset > > and issuperset refer to standard subsets and

[Python-ideas] Re: Instance method to test equivalence between set and iterable

2020-03-24 Thread Rob Cliffe via Python-ideas
On 23/03/2020 23:49, Steven D'Aprano wrote: On Mon, Mar 23, 2020 at 02:05:49PM +, Rob Cliffe via Python-ideas wrote: s = set("a") t = list("aa") s.issubset(t) True s.issuperset(t) True but it would be misleading IMO to say that s and t are in some sense equal. In *some* sense they

[Python-ideas] Re: Instance method to test equivalence between set and iterable

2020-03-24 Thread M.-A. Lemburg
Hi Steven, I think you are taking this a bit too far out of what we normal use Python for in real life :-) The mathematical complication of not having ∀x(x∈S ↔ x∈T) → S = T be a consequence of S = T → (∀x)(x∈S ↔ x∈T) which may sound weird to many people, originates in the fact that the above

[Python-ideas] Re: Instance method to test equivalence between set and iterable

2020-03-24 Thread Steven D'Aprano
Apologies in advance... the following is going to contain mathematical jargon and pedantry. Run now while you still can *wink* On Tue, Mar 24, 2020 at 12:56:55AM -0700, Andrew Barnert wrote: > >>> On Mar 23, 2020, at 19:52, Steven D'Aprano wrote: > >> On Mon, Mar 23, 2020 at 06:03:06PM -0700,

[Python-ideas] Re: Instance method to test equivalence between set and iterable

2020-03-24 Thread Andrew Barnert via Python-ideas
>>> On Mar 23, 2020, at 19:52, Steven D'Aprano wrote: >> On Mon, Mar 23, 2020 at 06:03:06PM -0700, Andrew Barnert wrote: >> The existing methods are named issubset and issuperset (and >> isdisjoint, which doesn’t have an operator near-equivalent). Given >> that, would you still want equals

[Python-ideas] Re: Instance method to test equivalence between set and iterable

2020-03-23 Thread Steven D'Aprano
On Mon, Mar 23, 2020 at 06:03:06PM -0700, Andrew Barnert wrote: > The existing methods are named issubset and issuperset (and > isdisjoint, which doesn’t have an operator near-equivalent). Given > that, would you still want equals instead of isequal or something? Oops! I mean, aha, you passed

[Python-ideas] Re: Instance method to test equivalence between set and iterable

2020-03-23 Thread Andrew Barnert via Python-ideas
> On Mar 23, 2020, at 16:57, Steven D'Aprano wrote: > > I shouldn't need to say this, but for the record I am not proposing and > do not want set equality to support lists; nor do I see the need for a > new method to perform "equivalent to equality" tests; but if the > consensus is that sets

[Python-ideas] Re: Instance method to test equivalence between set and iterable

2020-03-23 Thread Steven D'Aprano
On Mon, Mar 23, 2020 at 02:05:49PM +, Rob Cliffe via Python-ideas wrote: > >>> s = set("a") > >>> t = list("aa") > >>> s.issubset(t) > True > >>> s.issuperset(t) > True > > but it would be misleading IMO to say that s and t are in some sense > equal. In *some* sense they are equal: -

[Python-ideas] Re: Instance method to test equivalence between set and iterable

2020-03-23 Thread Greg Ewing
On 23/03/20 11:10 pm, M.-A. Lemburg wrote: The Python way is the mathematically correct way of interpreting the terms "subset" and "superset". Generally in maths it's usually more convenient if the simplest terminology includes edge cases. For example, the definition of a powerset would be

[Python-ideas] Re: Instance method to test equivalence between set and iterable

2020-03-23 Thread Rob Cliffe via Python-ideas
On 23/03/2020 09:12, Steven D'Aprano wrote: On Sun, Mar 22, 2020 at 08:55:47PM -0700, Andrew Barnert wrote: [...] But I don’t think that’s relevant here. You claimed that 'the "arbitrary iterables" part is a distraction', but I think it’s actually the whole point of the proposal. The initial

[Python-ideas] Re: Instance method to test equivalence between set and iterable

2020-03-23 Thread Guido van Rossum
< is the strict subset operator. <= is subset. What more can I say? On Mon, Mar 23, 2020 at 02:01 Steven D'Aprano wrote: > On Sun, Mar 22, 2020 at 09:49:26PM -0700, Guido van Rossum wrote: > > On Sun, Mar 22, 2020 at 6:51 PM Steven D'Aprano > wrote: > > > > > We might have a terminology issue

[Python-ideas] Re: Instance method to test equivalence between set and iterable

2020-03-23 Thread Chris Angelico
On Mon, Mar 23, 2020 at 8:00 PM Steven D'Aprano wrote: > > On Sun, Mar 22, 2020 at 09:49:26PM -0700, Guido van Rossum wrote: > > On Sun, Mar 22, 2020 at 6:51 PM Steven D'Aprano wrote: > > > > > We might have a terminology issue here, since according to Wikipedia > > > there is some dispute over

[Python-ideas] Re: Instance method to test equivalence between set and iterable

2020-03-23 Thread M.-A. Lemburg
On 3/23/2020 5:49 AM, Guido van Rossum wrote: > On Sun, Mar 22, 2020 at 6:51 PM Steven D'Aprano > wrote: > > We might have a terminology issue here, since according to Wikipedia > there is some dispute over whether or not to include the equality case > in

[Python-ideas] Re: Instance method to test equivalence between set and iterable

2020-03-23 Thread Steven D'Aprano
On Sun, Mar 22, 2020 at 08:55:47PM -0700, Andrew Barnert wrote: [...] > But I don’t think that’s relevant here. You claimed that 'the > "arbitrary iterables" part is a distraction', but I think it’s > actually the whole point of the proposal. The initial suggestion is > that there are lots of

[Python-ideas] Re: Instance method to test equivalence between set and iterable

2020-03-23 Thread Steven D'Aprano
On Sun, Mar 22, 2020 at 09:49:26PM -0700, Guido van Rossum wrote: > On Sun, Mar 22, 2020 at 6:51 PM Steven D'Aprano wrote: > > > We might have a terminology issue here, since according to Wikipedia > > there is some dispute over whether or not to include the equality case > > in subset/superset:

[Python-ideas] Re: Instance method to test equivalence between set and iterable

2020-03-22 Thread Guido van Rossum
On Sun, Mar 22, 2020 at 6:51 PM Steven D'Aprano wrote: > We might have a terminology issue here, since according to Wikipedia > there is some dispute over whether or not to include the equality case > in subset/superset: > > https://en.wikipedia.org/wiki/Subset > > For what it is worth, I'm in

[Python-ideas] Re: Instance method to test equivalence between set and iterable

2020-03-22 Thread Andrew Barnert via Python-ideas
> On Mar 22, 2020, at 18:54, Steven D'Aprano wrote: > > Do you have an example of `A <= B and B <= A` aside from the `A == B` > case? For mathematical sets, this is either impossible by definition, or impossible by 2-line proof, depending on which definitions you like. For Python sets,

[Python-ideas] Re: Instance method to test equivalence between set and iterable

2020-03-22 Thread Kyle Stanley
Steve Jorgensen wrote: > Basically, it is for a sense of completeness. It feels weird that there is a way to check whether an iterable is a subset of a set or a superset > of a set but no way to directly ask whether it is equivalent to the set. I can't say this has never happened historically,

[Python-ideas] Re: Instance method to test equivalence between set and iterable

2020-03-22 Thread Christopher Barker
> there is a way to check whether an iterable is a subset of a set or a > > superset of a set but no way to directly ask whether it is equivalent > > to the set. A_set == set(an_iterable) Seems straightforward to me :-) I see that subset will accept an arbitrary iterable, whereas __eq__ does

[Python-ideas] Re: Instance method to test equivalence between set and iterable

2020-03-22 Thread Steven D'Aprano
On Mon, Mar 23, 2020 at 12:08:23AM -, Steve Jorgensen wrote: > Basically, it is for a sense of completeness. It feels weird that > there is a way to check whether an iterable is a subset of a set or a > superset of a set but no way to directly ask whether it is equivalent > to the set. I

[Python-ideas] Re: Instance method to test equivalence between set and iterable

2020-03-22 Thread Steven D'Aprano
On Mon, Mar 23, 2020 at 12:03:50AM -, Steve Jorgensen wrote: > Every set is a superset of itself and a subset of itself. A set may > not be a "formal" subset or a "formal" superset of itself. `issubset` > and `issuperset` refer to standard subsets and supersets, not formal > subsets and

[Python-ideas] Re: Instance method to test equivalence between set and iterable

2020-03-22 Thread Steve Jorgensen
Paul Moore wrote: > On Sun, 22 Mar 2020 at 20:01, Steve Jorgensen ste...@stevej.name wrote: > > > > Currently, the issubset and > > issuperset methods of set objects accept arbitrary iterables as arguments. > > An > > iterable that is both a subset and superset is, in a sense, "equal" to the > >

[Python-ideas] Re: Instance method to test equivalence between set and iterable

2020-03-22 Thread Steve Jorgensen
Steven D'Aprano wrote: > On Sun, Mar 22, 2020 at 07:59:59PM -, Steve Jorgensen wrote: > > Currently, the issubset and > > issuperset methods of set objects > > accept arbitrary iterables as arguments. An iterable that is both a > > subset and superset is, in a sense, "equal" to the set. It

[Python-ideas] Re: Instance method to test equivalence between set and iterable

2020-03-22 Thread Steven D'Aprano
On Sun, Mar 22, 2020 at 07:59:59PM -, Steve Jorgensen wrote: > Currently, the `issubset` and `issuperset` methods of set objects > accept arbitrary iterables as arguments. An iterable that is both a > subset and superset is, in a sense, "equal" to the set. It would be > inappropriate for

[Python-ideas] Re: Instance method to test equivalence between set and iterable

2020-03-22 Thread Paul Moore
On Sun, 22 Mar 2020 at 20:01, Steve Jorgensen wrote: > > Currently, the `issubset` and `issuperset` methods of set objects accept > arbitrary iterables as arguments. An iterable that is both a subset and > superset is, in a sense, "equal" to the set. It would be inappropriate for > `==` to

[Python-ideas] Re: Instance method to test equivalence between set and iterable

2020-03-22 Thread Rob Cliffe via Python-ideas
On 22/03/2020 19:59, Steve Jorgensen wrote: Currently, the `issubset` and `issuperset` methods of set objects accept arbitrary iterables as arguments. An iterable that is both a subset and superset is, in a sense, "equal" to the set. It would be inappropriate for `==` to return `True` for

[Python-ideas] Re: Instance method to test equivalence between set and iterable

2020-03-22 Thread Steve Jorgensen
Bar Harel wrote: > Hey Steve, > How about set.symmetric_difference()? > Does it not do what you want? > Best regards, > Bar Harel > On Sun, Mar 22, 2020, 10:03 PM Steve Jorgensen ste...@stevej.name wrote: > > Currently, the issubset and > > issuperset methods of set objects accept > > arbitrary

[Python-ideas] Re: Instance method to test equivalence between set and iterable

2020-03-22 Thread Bar Harel
Hey Steve, How about set.symmetric_difference()? Does it not do what you want? Best regards, Bar Harel On Sun, Mar 22, 2020, 10:03 PM Steve Jorgensen wrote: > Currently, the `issubset` and `issuperset` methods of set objects accept > arbitrary iterables as arguments. An iterable that is both