Path: csiph.com!usenet.pasdenom.info!weretis.net!feeder4.news.weretis.net!ecngs!feeder2.ecngs.de!newsfeed.freenet.ag!news2.euro.net!newsgate.cistron.nl!newsgate.news.xs4all.nl!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.014 X-Spam-Evidence: '*H*': 0.97; '*S*': 0.00; 'subject:Python': 0.05; 'responding': 0.07; 'sep': 0.09; 'def': 0.10; 'alexander': 0.16; 'from:addr:rosuav': 0.16; 'from:name:chris angelico': 0.16; 'wrote:': 0.17; 'received:209.85.214.174': 0.21; 'header:In-Reply- To:1': 0.25; '[1]': 0.27; 'am,': 0.27; 'message- id:@mail.gmail.com': 0.27; 'there.': 0.28; 'clever': 0.29; 'though.': 0.29; 'fri,': 0.30; 'returned': 0.30; 'function': 0.30; 'to:addr:python-list': 0.33; 'received:google.com': 0.34; 'received:209.85': 0.35; 'but': 0.36; 'rather': 0.37; 'received:209': 0.37; 'subject:: ': 0.38; 'object': 0.38; 'to:addr:python.org': 0.39; 'received:209.85.214': 0.39; 'header:Received:5': 0.40; 'natural': 0.65; 'bot': 0.84 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=mime-version:in-reply-to:references:date:message-id:subject:from:to :content-type; bh=DhXZqgEvbak+XCVBwaUZRiBq91Nr9uGanWcgab4CKk0=; b=rLogs2CKrvclS0m5aE6yq+niQF3fO+dYxUmCdx0RvgMBhcJwH5waRNpWpZDYgvxAao OWp/TFhj7KGe6g8Io9KXLya66TVr0NIm8R3V7akr1fsfo/32iAakwur6A9JWmCH9uqZP tNooC/5QD2iybPorkTgxpChN4L0A4bAPjqEjfx0NammouTY8ClrcwIY3KTPY4mU7Tupx TAFCbFshm/r2PHSkykVTPo4zfe5jSE5J2oi6fnM093/Kj4uXTfz8sPa6RKrDIPtPRxDv TNNlzsAmnfJ6lwo9exxzWW0YSGhRL0eGI6JGj1QAYZ/rRm+VdyKSyRbSL7s8s+pSzcn3 qMbw== MIME-Version: 1.0 In-Reply-To: <50525f48$0$6573$9b4e6d93@newsspool3.arcor-online.net> References: <06a1a81b-246b-4e7b-ba34-4701f46889c8@googlegroups.com> <50525f48$0$6573$9b4e6d93@newsspool3.arcor-online.net> Date: Fri, 14 Sep 2012 08:38:43 +1000 Subject: Re: Python presentations From: Chris Angelico To: python-list@python.org Content-Type: text/plain; charset=ISO-8859-1 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: 31 NNTP-Posting-Host: 2001:888:2000:d::a6 X-Trace: 1347575926 news.xs4all.nl 6884 [2001:888:2000:d::a6]:51067 X-Complaints-To: abuse@xs4all.nl Xref: csiph.com comp.lang.python:29084 On Fri, Sep 14, 2012 at 8:33 AM, Alexander Blinne wrote: > On 13.09.2012 21:01, 88888 Dihedral wrote: >> def powerlist(x, n): >> # n is a natural number >> result=[] >> y=1 >> for i in xrange(n): >> result.append(y) >> y*=x >> return result # any object in the local function can be returned > > def powerlist(x, n): > result=[1] > for i in xrange(n-1): > result.append(result[-1]*x) > return result > > def powerlist(x,n): > if n==1: > return [1] > p = powerlist(x,n-1) > return p + [p[-1]*x] Eh, much simpler. def powerlist(x,n): return [x*i for i in xrange(n-1)] But you're responding to a bot there. Rather clever as bots go, though. ChrisA