cheers, much appreciated -ryan
On Thu, Oct 18, 2012 at 10:52 PM, Emile van Sebille <em...@fenx.com> wrote: > On 10/18/2012 10:38 AM, Ryan Waples wrote:> I'm struggling to understand > how to understand/accomplish the following: > > > > > I have an set ("a" below) and a list of sets ("not_a"), how can I pass > > the elements of "not_a" to set.difference() so that it it understands I > > want the difference between set "a" and all the rest > > > > set.difference says "Changed in version 2.6: Accepts multiple input > > iterables". > > How can I give it multiple input iterables? > > > > I get different error msgs depending on what I try, but they just tell > > me that there is something that I'm missing here. > > > > Thanks > > > > #Code below > > a = set([1,2,3,4]) > > b = set([2,3,4,5]) > > c = set([3,4,5,6]) > > d = set([4,5,6,7]) > > > > not_a = [b,c,d] > > a.difference(not_a) > > Try this as > > a.difference(*not_a) > > The '*' expands the list to its individual items. > > HTH, > > Emile > > > > > > > # I expect to return set([1]), the same as if I called: > > a.difference(b,c,d) > > > > > > > > > > ______________________________**_________________ > > Tutor maillist - Tutor@python.org > > To unsubscribe or change subscription options: > > http://mail.python.org/**mailman/listinfo/tutor<http://mail.python.org/mailman/listinfo/tutor> > > > > > ______________________________**_________________ > Tutor maillist - Tutor@python.org > To unsubscribe or change subscription options: > http://mail.python.org/**mailman/listinfo/tutor<http://mail.python.org/mailman/listinfo/tutor> >
_______________________________________________ Tutor maillist - Tutor@python.org To unsubscribe or change subscription options: http://mail.python.org/mailman/listinfo/tutor