Path: csiph.com!v102.xanadu-bbs.net!xanadu-bbs.net!feeder.erje.net!eu.feeder.erje.net!newsfeed.xs4all.nl!newsfeed2.news.xs4all.nl!xs4all!post.news.xs4all.nl!not-for-mail Return-Path: X-Original-To: python-list@python.org Delivered-To: python-list@mail.python.org X-Spam-Status: OK 0.080 X-Spam-Evidence: '*H*': 0.88; '*S*': 0.04; 'subject:question': 0.10; 'cc:addr:python-list': 0.11; 'count,': 0.16; 'itertools': 0.16; 'subject:python.': 0.16; 'wrote:': 0.18; '>>>': 0.22; 'import': 0.22; 'cc:addr:python.org': 0.22; 'math': 0.24; 'cc:2**0': 0.24; 'header:In-Reply-To:1': 0.27; 'message-id:@mail.gmail.com': 0.30; "i'm": 0.30; '>>>>': 0.31; 'received:google.com': 0.35; 'ian': 0.60; 'subject:. ': 0.67; '165': 0.84; 'subject:Very': 0.84; '2013': 0.98 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=mime-version:x-received:in-reply-to:references:date:message-id :subject:from:to:cc:content-type; bh=k481vb51/IIPnl/hn5k/ccUzH9NkDwQZzLuoz/pWRBU=; b=ohClzzeHe2oVYqcB9Jir7ZFIIbY8ghqF41VeEWgIiLJFVs+Nb3DR5ur0S/8kLtmKpo 6TAJq9VK9X70oW3VtSpgkVdGM3ucSzWIrN08es8fFju5MPuyrdOjh2QIMoet2xCwxHL8 HIcYPPPSk/5EJfe1IuDdU93cnCuvV7eWoUMx0pwIjnGiRvK+Uv4Z8+nBv7l5Lse8Vhb6 4tFFVbf/z6plAQqbNcHP4BKzTvTgWv1+bSSf3LGIck+ENTgVJJ8DRfc3vgpZS5uFoZnT A7Ag1Po3pK6MuGyFqNFtJUidKjsQn91CqaLhF3LYyZcRtXNKT6fgDqkK9NgXxsa3I3jR 6vSQ== MIME-Version: 1.0 X-Received: by 10.112.6.234 with SMTP id e10mr10303695lba.46.1365365794889; Sun, 07 Apr 2013 13:16:34 -0700 (PDT) In-Reply-To: <5161C7C5.6000908@feete.org> References: <5161C7C5.6000908@feete.org> Date: Sun, 7 Apr 2013 21:16:34 +0100 Subject: Re: Newbie to python. Very newbie question From: Arnaud Delobelle To: Ian Foote Content-Type: text/plain; charset=UTF-8 Cc: Python X-BeenThere: python-list@python.org X-Mailman-Version: 2.1.15 Precedence: list List-Id: General discussion list for the Python programming language List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Newsgroups: comp.lang.python Message-ID: Lines: 16 NNTP-Posting-Host: 2001:888:2000:d::a6 X-Trace: 1365365803 news.xs4all.nl 6957 [2001:888:2000:d::a6]:40085 X-Complaints-To: abuse@xs4all.nl Xref: csiph.com comp.lang.python:43016 On 7 April 2013 20:23, Ian Foote wrote: > I'm surprised no one has suggested: > >>>> import math >>>> sum( x*x for x in range(1, int(math.sqrt(100)), 2)) Yeah! And I'm surprised no one came up with: >>> from itertools import count, takewhile >>> sum(takewhile((100).__gt__, filter((2).__rmod__, map((2).__rpow__, count(1))))) 165 :) -- Arnaud