Re: set function

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • Kam-Hung Soh

    Re: set function

    On Sat, 17 May 2008 15:49:05 +1000, Beema shafreen
    <beema.shafreen @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_item s&i_items&j_ite ms
    >
    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>

Working...