any modules having a function to partition a list by predicate provided?

2010-04-19 Thread knifenomad
i know it's not very hard to get that solution. just by implementing simple function like below. def partition(target, predicate): split a list into two partitions with a predicate provided. any better ideas? :) true = []

Re: insert unique data in a list

2009-12-13 Thread knifenomad
On 12월14일, 오전2시57분, mattia ger...@gmail.com wrote: Il Sun, 13 Dec 2009 16:37:20 +, mattia ha scritto: How can I insert non-duplicate data in a list? I mean, is there a particular option in the creation of a list that permit me not to use something like: def append_unique(l, val):  

Re: insert unique data in a list

2009-12-13 Thread knifenomad
On 12월14일, 오전10시19분, knifenomad knifeno...@gmail.com wrote: On 12월14일, 오전2시57분, mattia ger...@gmail.com wrote: Il Sun, 13 Dec 2009 16:37:20 +, mattia ha scritto: How can I insert non-duplicate data in a list? I mean, is there a particular option in the creation of a list

Re: insert unique data in a list

2009-12-13 Thread knifenomad
On 12월14일, 오후12시42분, Steven D'Aprano ste...@remove.this.cybersource.com.au wrote: On Sun, 13 Dec 2009 17:19:17 -0800, knifenomad wrote: this makes the set type hashable. class Set(set):     __hash__ = lambda self: id(self) That's a *seriously* broken hash function. key = voila d