Re: set & random.choice question

2005-12-14 Thread Christophe Delord
Hello, On 14 Dec 2005 12:16:22 -0800, [EMAIL PROTECTED] wrote: > I want to do something like this: > > from random import choice > x = set(("jenny", "jacqui", "claire", "chris", "tracy")) > somebody = random.choice(x) > > but I bet a "TypeError: unindexable object" error. Any suggestions

Re: what list comprehension can't

2005-06-24 Thread Christophe Delord
Hello, On 24 Jun 2005 11:45:14 -0700, [EMAIL PROTECTED] wrote: > Hello, > > Can we impose if then else into list comprehension ? > Like we do in lambda-map form: > > This code change None into 0 > L = [None, 12] > R = map(lambda x: (x==None and [0] or x)[0], L) # [0,12] > Do you mean: [(x=

Re: Two questions on lambda:

2005-06-24 Thread Christophe Delord
hello, On Fri, 24 Jun 2005 14:48:16 +0200, Xavier Décoret wrote: > Hi, > > In the same spirit, how can I do to compute intermediary values in the > > body of a lambda function. Let's say (dummy example): > > f = lambda x : y=x*x,y+y > > > In languages like Caml, you can do: > > let f = func