Path: csiph.com!usenet.pasdenom.info!gegeweb.org!usenet-fr.net!nerim.net!novso.com!newsfeed.xs4all.nl!newsfeed5.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.007 X-Spam-Evidence: '*H*': 0.99; '*S*': 0.00; 'subject:Python': 0.05; 'responding': 0.07; 'python': 0.09; 'sep': 0.09; 'to:addr:comp.lang.python': 0.09; 'cc:addr:python-list': 0.10; 'def': 0.10; 'alexander': 0.16; 'wrote:': 0.17; 'cc:2**0': 0.23; 'cc:no real name:2**0': 0.24; 'cc:addr:python.org': 0.25; 'header :In-Reply-To:1': 0.25; 'header:User-Agent:1': 0.26; '[1]': 0.27; 'am,': 0.27; 'coding': 0.27; 'there.': 0.28; 'chris': 0.28; 'clever': 0.29; 'though.': 0.29; 'convert': 0.29; 'fri,': 0.30; 'returned': 0.30; 'function': 0.30; 'code': 0.31; 'received:google.com': 0.34; 'list': 0.35; 'from:addr:googlemail.com': 0.35; 'received:209.85': 0.35; 'but': 0.36; 'rather': 0.37; 'received:209': 0.37; 'subject:: ': 0.38; 'object': 0.38; 'some': 0.38; 'natural': 0.65; 'bot': 0.84; 'concept.': 0.84 Newsgroups: comp.lang.python Date: Thu, 13 Sep 2012 22:57:54 -0700 (PDT) In-Reply-To: Complaints-To: groups-abuse@google.com Injection-Info: glegroupsg2000goo.googlegroups.com; posting-host=123.192.32.215; posting-account=5JdMBQoAAABHnS4mjpqEzxnmWtgiiVNw References: <06a1a81b-246b-4e7b-ba34-4701f46889c8@googlegroups.com> <50525f48$0$6573$9b4e6d93@newsspool3.arcor-online.net> User-Agent: G2/1.0 X-Google-Web-Client: true X-Google-IP: 123.192.32.215 MIME-Version: 1.0 Subject: Re: Python presentations From: 88888 Dihedral To: comp.lang.python@googlegroups.com Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: quoted-printable Cc: python-list@python.org 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: , Message-ID: Lines: 73 NNTP-Posting-Host: 2001:888:2000:d::a6 X-Trace: 1347602283 news.xs4all.nl 6859 [2001:888:2000:d::a6]:46747 X-Complaints-To: abuse@xs4all.nl Xref: csiph.com comp.lang.python:29123 Chris Angelico=E6=96=BC 2012=E5=B9=B49=E6=9C=8814=E6=97=A5=E6=98=9F=E6=9C= =9F=E4=BA=94UTC+8=E4=B8=8A=E5=8D=886=E6=99=8239=E5=88=8625=E7=A7=92=E5=AF= =AB=E9=81=93=EF=BC=9A > On Fri, Sep 14, 2012 at 8:33 AM, Alexander Blinne wrote= : >=20 > > On 13.09.2012 21:01, 88888 Dihedral wrote: >=20 > >> def powerlist(x, n): >=20 > >> # n is a natural number >=20 > >> result=3D[] >=20 > >> y=3D1 >=20 > >> for i in xrange(n): >=20 > >> result.append(y) >=20 > >> y*=3Dx >=20 > >> return result # any object in the local function can be returned >=20 > > >=20 > > def powerlist(x, n): >=20 > > result=3D[1] >=20 > > for i in xrange(n-1): >=20 > > result.append(result[-1]*x) >=20 > > return result >=20 > > >=20 > > def powerlist(x,n): >=20 > > if n=3D=3D1: >=20 > > return [1] >=20 > > p =3D powerlist(x,n-1) >=20 > > return p + [p[-1]*x] >=20 >=20 >=20 > Eh, much simpler. >=20 >=20 >=20 > def powerlist(x,n): >=20 > return [x*i for i in xrange(n-1)] >=20 >=20 >=20 > But you're responding to a bot there. Rather clever as bots go, though. >=20 >=20 >=20 > ChrisA I do not object the list comprehension in concept.=20 But I have to convert python code to cython from time to time. Well, this imposes some coding style definitely. =20