On May 4, 11:34 am, Peter Otten <[EMAIL PROTECTED]> wrote: > [EMAIL PROTECTED] wrote: > > It is not possible to index set objects. That is OK. > > But, what if I want to find some element from the Set. > > > from sets import Set > > s = Set( range(12 ) > > > if I do pop, that particular element gets removed. > > I do not want to remove the element, but get some element > > from the Set. > > > s.some_element() # Is not available > > > Is there a way to do this. I am doing it like this: > > > for x in s: break > > > Now x is /some_element/ from s. > > A set is probably not the appropriate container then. What is your use case? > > Peter
Peter, I need to do a lot of union and intersection operations on these elements. So, set is a must for me in this case. In the particular case, I have to read an attribute from any one of the elements, which one doesn't matter because this attribute value is same across all elements in the set. - Suresh -- http://mail.python.org/mailman/listinfo/python-list