Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > Python > Re: Membership of multiple items to a list

Reply
Thread Tools

Re: Membership of multiple items to a list

 
 
Stephen Hansen
Guest
Posts: n/a
 
      02-01-2009
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v2.0.10 (Darwin)
Comment: Public key available at: http://killnine.net/shansen.pub

iEYEARECAAYFAkmF/4gACgkQEKJsw6Mia26+ngCdEkeE/OiJXbWpABL47QAd7T+X
u1EAnR/jpjkT1rVnPFRW7iAYGD055h1l
=E9aU
-----END PGP SIGNATURE-----

 
Reply With Quote
 
 
 
 
inkhorn
Guest
Posts: n/a
 
      02-01-2009
Wow thanks for the lightning fast reply! This does exactly the right
job.

Matt

On Feb 1, 3:01*pm, Stephen Hansen <(E-Mail Removed)> wrote:
> I'd like to know how to elegantly check a list for the membership of
> any of its items to another list. *Not caring for elegance, I would
> use the following code:
> That's one of the useful properties of sets:
> >>> a = [1,2,3]
> >>> b = [3,4,5,6]
> >>> set(a) & set(b)

> set([3])
> >>> set(a).intersection(b)

> set([3])
> That's two spellings of the same thing. As for testing: an empty set like an empty list will return false, so "if set(a) & set(b):" will be true or false based on if there's any commonalities between the two lists.
> --Stephen
>
> *signature.asc
> < 1KViewDownload


 
Reply With Quote
 
 
 
 
Steven D'Aprano
Guest
Posts: n/a
 
      02-02-2009
On Sun, 01 Feb 2009 12:01:11 -0800, Stephen Hansen wrote:

> <br><div class="gmail_quote"><blockquote class="gmail_quote"
> style="border-left: 1px solid rgb(204, 204, 204); margin: 0pt 0pt 0pt
> 0.8ex; padding-left: 1ex;"><br> I'd like to know how to elegantly check
> a list for the membership of<br> any of its items to another list.
> &nbsp;Not caring for elegance, I would<br> use the following code:<br>
> </blockquote><div><br>That's one of the useful properties of
> sets:<br><br>&gt;&gt;&gt; a = [1,2,3]<br>&gt;&gt;&gt; b =
> [3,4,5,6]<br>&gt;&gt;&gt; set(a) &amp;
> set(b)<br>set([3])<br>&gt;&gt;&gt;
> set(a).intersection(b)<br>set([3])<br> <br>That's two spellings of the
> same thing. As for testing: an empty set like an empty list will return
> false, so "if set(a) &amp; set(b):" will be true or false based on if
> there's any commonalities between the two
> lists.<br><br>--Stephen</div></div><br>



Stephen, do you see the utter mess your posts look like to some others?

Please ensure you send plain text messages to Usenet, not HTML. If you
absolutely can't avoid using an insecure and bloated page layout language
instead of text, please ensure that your News or mail client is set to
send plain text as well as HTML.

If your news/mail client doesn't follow Usenet standards, then (1) change
the application you use to one that does; or (2) complain to the vendor
until they fix their product.


Thank you,



--
Steven
 
Reply With Quote
 
rdmurray@bitdance.com
Guest
Posts: n/a
 
      02-02-2009
Quoth Steven D'Aprano <(E-Mail Removed)>:
> On Sun, 01 Feb 2009 12:01:11 -0800, Stephen Hansen wrote:
>
> > <br><div class="gmail_quote"><blockquote class="gmail_quote"
> > style="border-left: 1px solid rgb(204, 204, 204); margin: 0pt 0pt 0pt
> > 0.8ex; padding-left: 1ex;"><br> I'd like to know how to elegantly check
> > a list for the membership of<br> any of its items to another list.
> > &nbsp;Not caring for elegance, I would<br> use the following code:<br>
> > </blockquote><div><br>That's one of the useful properties of
> > sets:<br><br>&gt;&gt;&gt; a = [1,2,3]<br>&gt;&gt;&gt; b =
> > [3,4,5,6]<br>&gt;&gt;&gt; set(a) &amp;
> > set(b)<br>set([3])<br>&gt;&gt;&gt;
> > set(a).intersection(b)<br>set([3])<br> <br>That's two spellings of the
> > same thing. As for testing: an empty set like an empty list will return
> > false, so "if set(a) &amp; set(b):" will be true or false based on if
> > there's any commonalities between the two
> > lists.<br><br>--Stephen</div></div><br>

>
>
> Stephen, do you see the utter mess your posts look like to some others?


I don't even see Stephen Hansen's posts. My newsreader just shows the
header and says "[HTML part not displayed]".

--RDM

 
Reply With Quote
 
Stephen Hansen
Guest
Posts: n/a
 
      02-02-2009
> Stephen, do you see the utter mess your posts look like to some others?

Whoops, I was experimenting with a new Firefox add-on that fiddled
with Gmail, and hadn't noticed it changed my output format to HTML out
from under me.

Sorry!

--S
 
Reply With Quote
 
Stephen Hansen
Guest
Posts: n/a
 
      02-02-2009
On Sun, Feb 1, 2009 at 7:47 PM, Ben Finney
<(E-Mail Removed)> wrote:
> http://www.velocityreviews.com/forums/(E-Mail Removed) writes:
>
>> I don't even see Stephen Hansen's posts. My newsreader just shows
>> the header and says "[HTML part not displayed]".

>
> Likewise.


Yeah, I know HTML is bad on newsgroups. I didn't realize that when I
installed FireGPG to sign messages while in Gmail that it started
handling my html/plain text content differently.

Oops.

That said: Is S/MIME / OpenPGP readable on these various clients?
There's no HTML, the text body is just encoded in base64.

I haven't actually subscribed to a usenet newsgroup in eons upon eons.

If its not readable as S/MIME then I'll switch to inline PGP... that's
just a slightly terrible solution for other places I have to talk and
I'll have to take extra care to remember to manually check the
settings based upon where I'm talking.

I'm re-sending this same message as the OpenPGP S/MIME attachment
format -- just so test if its actually readable by news clients in
general. I have absolutely no idea. Not touched a news client in years
and years, as I said.

Sorry for the inconvenience.

--Stephen
 
Reply With Quote
 
 
 
Reply

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
resolve single line with multiple items into mutliple lines, single items ela Perl Misc 12 04-06-2009 06:47 PM
Membership of multiple items to a list inkhorn Python 1 02-01-2009 08:00 PM
unable to retrieve listbox items on postback , items moved usingjavascript between 2 list boxes (source and target ) divya ASP .Net 1 05-28-2008 05:27 AM
Is there any way to append some items to List box, without retrieving all items through AJAX? Anjan Bhowmik ASP .Net 1 02-14-2008 09:02 PM
grouping items among a list according to items subtag value Gilles Kuhn XML 0 09-15-2003 12:01 PM



Advertisments