Re: question regarding list comprehensions

2008-10-20 Thread Pat
Diez B. Roggisch wrote: Pat wrote: I have written chunks of Python code that look this: new_array = [] for a in array: if not len( a ): continue new_array.append( a ) new_array = [a for a in array if len(a)] and... string = "" for r in r

Re: question regarding list comprehensions

2008-10-20 Thread Pat
Steven D'Aprano wrote: On Mon, 20 Oct 2008 10:20:03 -0400, Pat wrote: Finally, if someone could point me to a good tutorial or explain list compressions I would be forever in your debt. Think of a for-loop: for x in (1, 2, 3): x Creates x=1, then x=2, then x=3. It doesn't do anything wi

Re: question regarding list comprehensions

2008-10-20 Thread Bruno Desthuilliers
Pat a écrit : I have written chunks of Python code that look this: new_array = [] for a in array: if not len( a ): continue new_array.append( a ) # à la lisp new_array = filter(None, array) # à la haskell new_array = [a for a in array if a] NB : all built

Re: question regarding list comprehensions

2008-10-20 Thread Steven D'Aprano
On Mon, 20 Oct 2008 10:20:03 -0400, Pat wrote: > Finally, if someone could point me to a good tutorial or explain list > compressions I would be forever in your debt. Think of a for-loop: for x in (1, 2, 3): x Creates x=1, then x=2, then x=3. It doesn't do anything with the x's, but just c

Re: question regarding list comprehensions

2008-10-20 Thread Diez B. Roggisch
Pat wrote: > I have written chunks of Python code that look this: > > new_array = [] > for a in array: > if not len( a ): > continue > new_array.append( a ) new_array = [a for a in array if len(a)] > and... > > string = "" > for r in results:

question regarding list comprehensions

2008-10-20 Thread Pat
I have written chunks of Python code that look this: new_array = [] for a in array: if not len( a ): continue new_array.append( a ) and... string = "" for r in results: if not r.startswith( '#' ): string =+ r It seems that a list