Silly question

David C Ullrich dullrich at sprynet.com
Fri Aug 21 15:40:30 EDT 2009


On Thu, 20 Aug 2009 16:51:00 -0700, Aahz wrote:

> In article <mailman.143.1250793404.2854.python-list at python.org>,
> Benjamin Kaplan  <benjamin.kaplan at case.edu> wrote:
>>On Thu, Aug 20, 2009 at 2:13 PM, David C Ullrich<dullrich at sprynet.com>
>>wrot= e:
>>>
>>> I just noticed that
>>> sequence[i:j:k]
>>
>>Well, I got some good news and some bad news. According to the docs, it
>>existed in 1.4 but the built-in sequences didn't support it until 2.3.
>>It's not used that often anyway so you haven't been missing much.
> 
> Except that it's canonical for one specific operation:
> 
> 'reverseme'[::-1]

It's like you guys are a bunch of programmers or something:

from math import sqrt

def Primes(n):
  """Return a list of the primes < n"""
  sieve = range(n)
  for k in range(2,int(sqrt(n))+2):
    sieve[::k] = [1]*((n+k-1)/k)
  return [p for p in sieve if p > 1]







More information about the Python-list mailing list