Re: [Tutor] creating new dictionary based on membership testing

2009-03-09 Thread ski
thank you all, great feedback. Sander Sweers wrote: 2009/3/9 A.T.Hofkamp : You can do something like [d for d in d1 if d['is_selected'] == False] to get your dicts. If 'is_selected' is not always present, it gets a bit more complicated, I'll leave that as an exercise for the interested reader

Re: [Tutor] creating new dictionary based on membership testing

2009-03-09 Thread Kent Johnson
On Mon, Mar 9, 2009 at 10:28 AM, ski wrote: > hello, > > i have this list which contains a number of dictionaries. > d1 = [{'is_selected': False, 'id': 'AAC', 'title': 'Association of Airline Cons.'}, {'is_selected': False, 'id': 'AALA', 'title': 'Adv. Activity Licence. Auth.'}, {'is

Re: [Tutor] creating new dictionary based on membership testing

2009-03-09 Thread Sander Sweers
2009/3/9 A.T.Hofkamp : > You can do something like > [d for d in d1 if d['is_selected'] == False] > to get your dicts. > > If 'is_selected' is not always present, it gets a bit more complicated, I'll > leave that as an exercise for the interested reader :) You would use d.get('is_selected', False)

Re: [Tutor] creating new dictionary based on membership testing

2009-03-09 Thread A.T.Hofkamp
ski wrote: hello, i have this list which contains a number of dictionaries. >>>d1 = [{'is_selected': False, 'id': 'AAC', 'title': 'Association of Airline Cons.'}, {'is_selected': False, 'id': 'AALA', 'title': 'Adv. Activity Licence. Auth.'}, {'is_selected': False, 'id': 'ABPCO', 'title': 'A

[Tutor] creating new dictionary based on membership testing

2009-03-09 Thread ski
hello, i have this list which contains a number of dictionaries. >>>d1 = [{'is_selected': False, 'id': 'AAC', 'title': 'Association of Airline Cons.'}, {'is_selected': False, 'id': 'AALA', 'title': 'Adv. Activity Licence. Auth.'}, {'is_selected': False, 'id': 'ABPCO', 'title': 'Association of