[lnkForumImage]
TotalShareware - Download Free Software

Confronta i prezzi di migliaia di prodotti.
Asp Forum
 Home | Login | Register | Search 


 

Forums >

comp.lang.python

Re: Why this apparent assymetry in set operations?

Neil Cerutti

1/15/2008 4:51:00 PM

On Jan 15, 2008 11:07 AM, Skip Montanaro <skip@pobox.com> wrote:
> > > Why is that? Doesn't the |= operator essentially map to an update() call?
> >
> > No, according to 3.7 Set Types, s | t maps to s.union(t).
>
> I was asking about the |= assignment operator which according to the
> docs *does* map to the update method.

Oops! You're right. That's surprising.

This inconsistency is due to the c implementation.

Internally, |= maps to the c function set_ior, while .update(...) maps
to set_update.

Both eventually call set_update_internal, which works fine when the
operand is not a set.

But set_ior specifically punts non-sets before calling set_update_internal.

So this is a bug in set_update or in set_ior. They can't both be
right.

--
Neil Cerutti <mr.cerutti+python@gmail.com>
7 Answers

chris.monsanto

1/15/2008 5:07:00 PM

0

On Jan 15, 11:51 am, "Neil Cerutti" <mr.ceru...@gmail.com> wrote:
>
> So this is a bug in set_update or in set_ior. They can't both be
> right.
>

It's not a bug.

"Note, the non-operator versions of union(), intersection(),
difference(), and symmetric_difference(), issubset(), and issuperset()
methods will accept any iterable as an argument. In contrast, their
operator based counterparts require their arguments to be sets. This
precludes error-prone constructions like set('abc') & 'cbs' in favor
of the more readable set('abc').intersection('cbs')."

Paul Rubin

1/15/2008 6:23:00 PM

0

Chris M <chris.monsanto@gmail.com> writes:
> precludes error-prone constructions like set('abc') & 'cbs' in favor
> of the more readable set('abc').intersection('cbs')."

set('abc') & set('cbs')

Neil Cerutti

1/15/2008 6:25:00 PM

0

On Jan 15, 2008 12:06 PM, Chris M <chris.monsanto@gmail.com> wrote:
> On Jan 15, 11:51 am, "Neil Cerutti" <mr.ceru...@gmail.com> wrote:
> >
> > So this is a bug in set_update or in set_ior. They can't both be
> > right.
> >
>
> It's not a bug.
>
> "Note, the non-operator versions of union(), intersection(),
> difference(), and symmetric_difference(), issubset(), and issuperset()
> methods will accept any iterable as an argument. In contrast, their
> operator based counterparts require their arguments to be sets. This
> precludes error-prone constructions like set('abc') & 'cbs' in favor
> of the more readable set('abc').intersection('cbs')."

Thanks. That neatly answers Skip's question, assuming he buys the
putative error pronicity. The docs say the design is based on lessons
learned from the sets module, so that also explains why it's different
from the module version, as well.

--
Neil Cerutti <mr.cerutti+python@gmail.com>

RichL

7/6/2011 9:58:00 PM

0

"who?" <yourimageunreels@sbcglobal.net> wrote in message
news:a3c752a7-d51c-4bd0-b1e5-3e6d548f7a26@gv8g2000vbb.googlegroups.com...
> On Jul 6, 3:56 am, Fattuchus <fattuc...@yahoo.com> wrote:
>> On Jul 5, 11:50 pm, abe slaney <abesla...@yahoo.com> wrote:
>>
>>
>>
>>
>>
>>
>>
>>
>>
>> > On Jul 5, 8:15 pm, The Lone Star <from_me_to_...@comcast.net> wrote:
>>
>> > > Exactly, Danny!
>>
>> > > After all, would you use your hands to pick poison ivy and a rose to
>> > > make something for your lapel?
>>
>> > Obsess much?
>> > A 12-year old could read the posts and tell they're not from the same
>> > person. And you taught English? I doubt very much that either Jeff or
>> > Danny believe as you do. And you've pulled the same kind of lame and
>> > baseless accusations against me...no matter how many times I told you
>> > plainly that I only post here under one nym you continually intimated
>> > otherwise. What need would PR have to snipe from a pseudonym? Did you
>> > ever get the feeling he was holding back and not saying exactly what
>> > he thought under his regular nym? Think.
>>
>> I don't think anyone here believes for one second you are the
>> troll(s).
>
> No way. It's just my opinion, but I think a troll is someone who
> got their feelings hurt here at one time.

Some apparently think PR is the troll (not abe), which I think is absurd.
The "troll" doesn't write in PR's style, and as others have pointed out PR
never hesisted to act like an asshole when he wanted to, using his own name.

What I don't get is why are people even responding to him, since everyone
seems to concede he's a troll?

Danny McEvoy

7/6/2011 11:32:00 PM

0

On Jul 6, 4:50 am, abe slaney <abesla...@yahoo.com> wrote:
> On Jul 5, 8:15 pm, The Lone Star <from_me_to_...@comcast.net> wrote:
>
> > Exactly, Danny!
>
> > After all, would you use your hands to pick poison ivy and a rose to
> > make something for your lapel?
>
> Obsess much?
> A 12-year old could read the posts and tell they're not from the same
> person. And you taught English? I doubt very much that either Jeff or
> Danny believe as you do. And you've pulled the same kind of lame and
> baseless accusations against me...no matter how many times I told you
> plainly that I only post here under one nym you continually intimated
> otherwise. What need would PR have to snipe from a pseudonym? Did you
> ever get the feeling he was holding back and not saying exactly what
> he thought under his regular nym? Think.

I don't think Robert was suggesting you were the mentally ill troll
Abe...FWIW..obviously you are not the mentally ill troll!! (neither is
PR who thankfully has disappeared from our lives recently..giving us
all some respite)....the last word from me on the matter..the MIT
deserves a response not..and sadly here am I giving a response..so I
won't talk about it again.

Danny

Fattuchus

7/7/2011 8:36:00 AM

0

On Jul 6, 5:58 pm, "RichL" <rpleav...@yahoo.com> wrote:
> "who?" <yourimageunre...@sbcglobal.net> wrote in message
>
> news:a3c752a7-d51c-4bd0-b1e5-3e6d548f7a26@gv8g2000vbb.googlegroups.com...
>
>
>
>
>
> > On Jul 6, 3:56 am, Fattuchus <fattuc...@yahoo.com> wrote:
> >> On Jul 5, 11:50 pm, abe slaney <abesla...@yahoo.com> wrote:
>
> >> > On Jul 5, 8:15 pm, The Lone Star <from_me_to_...@comcast.net> wrote:
>
> >> > > Exactly, Danny!
>
> >> > > After all, would you use your hands to pick poison ivy and a rose to
> >> > > make something for your lapel?
>
> >> > Obsess much?
> >> > A 12-year old could read the posts and tell they're not from the same
> >> > person. And you taught English? I doubt very much that either Jeff or
> >> > Danny believe as you do. And you've pulled the same kind of lame and
> >> > baseless accusations against me...no matter how many times I told you
> >> > plainly that I only post here under one nym you continually intimated
> >> > otherwise. What need would PR have to snipe from a pseudonym? Did you
> >> > ever get the feeling he was holding back and not saying exactly what
> >> > he thought under his regular nym? Think.
>
> >> I don't think anyone here believes for one second you are the
> >> troll(s).
>
> > No way. It's just my opinion, but I think a troll is someone who
> > got their feelings hurt here at one time.
>
> Some apparently think PR is the troll (not abe), which I think is absurd.
> The "troll" doesn't write in PR's style, and as others have pointed out PR
> never hesisted to act like an asshole when he wanted to, using his own name.
>
> What I don't get is why are people even responding to him, since everyone
> seems to concede he's a troll?-

We agree completely, but you won't read this.

Jeff

7/7/2011 9:38:00 AM

0

On Jul 6, 4:58 pm, "RichL" <rpleav...@yahoo.com> wrote:
> "who?" <yourimageunre...@sbcglobal.net> wrote in message
>
> news:a3c752a7-d51c-4bd0-b1e5-3e6d548f7a26@gv8g2000vbb.googlegroups.com...
>
>
>
>
>
>
>
>
>
> > On Jul 6, 3:56 am, Fattuchus <fattuc...@yahoo.com> wrote:
> >> On Jul 5, 11:50 pm, abe slaney <abesla...@yahoo.com> wrote:
>
> >> > On Jul 5, 8:15 pm, The Lone Star <from_me_to_...@comcast.net> wrote:
>
> >> > > Exactly, Danny!
>
> >> > > After all, would you use your hands to pick poison ivy and a rose to
> >> > > make something for your lapel?
>
> >> > Obsess much?
> >> > A 12-year old could read the posts and tell they're not from the same
> >> > person. And you taught English? I doubt very much that either Jeff or
> >> > Danny believe as you do. And you've pulled the same kind of lame and
> >> > baseless accusations against me...no matter how many times I told you
> >> > plainly that I only post here under one nym you continually intimated
> >> > otherwise. What need would PR have to snipe from a pseudonym? Did you
> >> > ever get the feeling he was holding back and not saying exactly what
> >> > he thought under his regular nym? Think.
>
> >> I don't think anyone here believes for one second you are the
> >> troll(s).
>
> > No way. It's just my opinion, but I think a troll is someone who
> > got their feelings hurt here at one time.
>
> Some apparently think PR is the troll (not abe), which I think is absurd.

I agree. I don't think the troll is PR.

> The "troll" doesn't write in PR's style, and as others have pointed out PR
> never hesisted to act like an asshole when he wanted to, using his own name.

Right.

> What I don't get is why are people even responding to him, since everyone
> seems to concede he's a troll?

Yeah, well, I have responded to him making suggestions of things he
could do that he would be more satisfied doing. You know, like
sending him a backing track of a guitar so he could put music
on Youtube.....since he doesn't like Danny....but without success.
I still think the troll is that King Sized Johnson poster cause
nobody hassled Danny until he arrived. Whoever it is can remain
unhappy. I tried my best to help.

Not much else to suggest. He can be unhappy. I tried.