Re: I'm starting to think like a Pythonista

2007-10-11 Thread Bjoern Schliessmann
brad wrote: > Bjoern Schliessmann wrote: >> Why use xrange if you convert it to a full list in place? No >> advantage there. > > What is the dis-advantage of using xrange over range in this > circumstance? Hardly any, but honestly: Converting it to a list manually is more than superfluous. Rega

Re: I'm starting to think like a Pythonista

2007-10-10 Thread Erik Jones
On Oct 10, 2007, at 4:16 PM, Marc 'BlackJack' Rintsch wrote: > On Wed, 10 Oct 2007 17:03:41 -0400, brad wrote: > >> Bjoern Schliessmann wrote: >>> brad wrote: low_odds = [1,3,5,7,9] # make a list containing 10 - 98 evens only big_evens = big_evens = [x for x in list(xrange(99)) if

Re: I'm starting to think like a Pythonista

2007-10-10 Thread Marc 'BlackJack' Rintsch
On Wed, 10 Oct 2007 17:03:41 -0400, brad wrote: > Bjoern Schliessmann wrote: >> brad wrote: >>> low_odds = [1,3,5,7,9] >>> # make a list containing 10 - 98 evens only >>> big_evens = big_evens = [x for x in list(xrange(99)) if x % 2 == >>> 0 and x >8] >> >> Why use xrange if you convert it to a

Re: I'm starting to think like a Pythonista

2007-10-10 Thread brad
Erik Jones wrote: > big_evens = range(10, 100, 2) > big_odds = range(11, 100, 2) Neat, but not as clever or as hard to read as mine... I'll bet it faster though... maybe not. The upto part is here: ok_numbers = low_odds + big_evens + [x for x in low_evens if x <= y] -- http://mail.python.org

Re: I'm starting to think like a Pythonista

2007-10-10 Thread brad
Bjoern Schliessmann wrote: > brad wrote: >> low_odds = [1,3,5,7,9] >> # make a list containing 10 - 98 evens only >> big_evens = big_evens = [x for x in list(xrange(99)) if x % 2 == >> 0 and x >8] > > Why use xrange if you convert it to a full list in place? No > advantage there. What is the dis

Re: I'm starting to think like a Pythonista

2007-10-10 Thread Bjoern Schliessmann
brad wrote: > low_odds = [1,3,5,7,9] > # make a list containing 10 - 98 evens only > big_evens = big_evens = [x for x in list(xrange(99)) if x % 2 == > 0 and x >8] Why use xrange if you convert it to a full list in place? No advantage there. Regards, Björn -- BOFH excuse #300: Digital Manipu

Re: I'm starting to think like a Pythonista

2007-10-10 Thread Erik Jones
On Oct 10, 2007, at 2:51 PM, brad wrote: > I was looking at a way to implement Ruby's upto method in python. I > came > up with the code below... three years ago, I would never have > thought of > list comprehension, today it seems second nature. This may be totally > un-Pythonic, but I thoug

I'm starting to think like a Pythonista

2007-10-10 Thread brad
I was looking at a way to implement Ruby's upto method in python. I came up with the code below... three years ago, I would never have thought of list comprehension, today it seems second nature. This may be totally un-Pythonic, but I thought it was kind of clever. Man, for some reason, I feel