471,108 Members | 1,298 Online
Bytes | Software Development & Data Engineering Community
Post +

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 471,108 software developers and data experts.

Re: set function

On Sat, 17 May 2008 15:49:05 +1000, Beema shafreen
<be************@gmail.comwrote:
Hi all,
I need to find the intersection of 10 different files with ids definedas
a_items, b_items and so on

common_items = a_items&b_items&c_items&\
d_items&e_items&f_items\
&g_items&h_items&i_items&j_items

i have included above line in the script
is this an right way will my program accept it or what are the other
option
to compare 10 different such items
See "Set Types", http://docs.python.org/lib/types-set.html. Example:

s1 = set([1,2,3])
s2 = set([3,4,5])
s1 & s2
set([3])

You can populate your sets using an iterable, such as the lines from a
file. Example:

s1 = set(file(r'blah.txt'))

--
Kam-Hung Soh <a href="http://kamhungsoh.com/blog">Software Salariman</a>

Jun 27 '08 #1
0 661

This discussion thread is closed

Replies have been disabled for this discussion.

Similar topics

3 posts views Thread by domeceo | last post: by
5 posts views Thread by phil_gg04 | last post: by
2 posts views Thread by laredotornado | last post: by
2 posts views Thread by sushil | last post: by
8 posts views Thread by Olov Johansson | last post: by

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.