Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
Groups > comp.lang.python > #19852
| Path | csiph.com!x330-a1.tempe.blueboxinc.net!usenet.pasdenom.info!weretis.net!feeder1.news.weretis.net!feeder.erje.net!newsfeed.xs4all.nl!newsfeed6.news.xs4all.nl!xs4all!newsgate.cistron.nl!newsgate.news.xs4all.nl!post.news.xs4all.nl!not-for-mail |
|---|---|
| Return-Path | <chris@rebertia.com> |
| X-Original-To | python-list@python.org |
| Delivered-To | python-list@mail.python.org |
| X-Spam-Status | OK 0.011 |
| X-Spam-Evidence | '*H*': 0.98; '*S*': 0.00; 'python.': 0.04; 'subject:Python': 0.05; 'python': 0.08; 'def': 0.13; 'cc:addr :python-list': 0.15; 'antti': 0.16; 'closures': 0.16; 'curiosity,': 0.16; 'wrote:': 0.16; 'cheers,': 0.20; 'cc:no real name:2**0': 0.21; 'feb': 0.22; 'header:In-Reply-To:1': 0.22; 'received:209.85.212.46': 0.23; 'received:mail- vw0-f46.google.com': 0.23; 'cc:2**0': 0.25; 'pm,': 0.26; 'function': 0.27; 'message-id:@mail.gmail.com': 0.28; 'cc:addr:python.org': 0.29; 'fri,': 0.30; 'chris': 0.30; 'usually': 0.30; 'skip:- 30': 0.33; 'done': 0.33; 'read,': 0.33; 'follows:': 0.34; 'received:209.85.212': 0.34; 'received:google.com': 0.37; 'received:209.85': 0.38; 'several': 0.38; 'subject:with': 0.38; 'received:209': 0.39; 'subject:: ': 0.39; 'kept': 0.68; 'calls,': 0.84; 'sender:addr:chris': 0.84; '\xc2\xa0it': 0.84 |
| DKIM-Signature | v=1; a=rsa-sha256; c=relaxed/relaxed; d=rebertia.com; s=google; h=mime-version:sender:in-reply-to:references:date :x-google-sender-auth:message-id:subject:from:to:cc:content-type :content-transfer-encoding; bh=poIRTh5JZUbLAo3ODIGW5cFREct2G443dO7vXhgcYww=; b=AZW17zAGMi/E4C6ssBxcFPwxHDLL6UhSGW8llFf40lR1qemCSm1oyqtkulk512vEU9 YFrxrJi4dEsKz+y1Hho/qnZ4LMV4EF/MYM3c/HvEvpDWBN0e+HCEcJzx5z2uJeprC2r6 zAG78UbYR+IdvTQBeadPLK2p9auHw7D7iwQCU= |
| MIME-Version | 1.0 |
| Sender | chris@rebertia.com |
| In-Reply-To | <dY_Wq.11747$I33.10275@uutiset.elisa.fi> |
| References | <dY_Wq.11747$I33.10275@uutiset.elisa.fi> |
| Date | Fri, 3 Feb 2012 18:47:20 -0800 |
| X-Google-Sender-Auth | 0TAlDte6wCiaDQD4T9tcXO1JgsU |
| Subject | Re: Common LISP-style closures with Python |
| From | Chris Rebert <clp2@rebertia.com> |
| To | Antti J Ylikoski <antti.ylikoski@tkk.fi> |
| 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.12 |
| Precedence | list |
| List-Id | General discussion list for the Python programming language <python-list.python.org> |
| List-Unsubscribe | <http://mail.python.org/mailman/options/python-list>, <mailto:python-list-request@python.org?subject=unsubscribe> |
| List-Archive | <http://mail.python.org/pipermail/python-list> |
| List-Post | <mailto:python-list@python.org> |
| List-Help | <mailto:python-list-request@python.org?subject=help> |
| List-Subscribe | <http://mail.python.org/mailman/listinfo/python-list>, <mailto:python-list-request@python.org?subject=subscribe> |
| Newsgroups | comp.lang.python |
| Message-ID | <mailman.5426.1328323649.27778.python-list@python.org> (permalink) |
| Lines | 30 |
| NNTP-Posting-Host | 2001:888:2000:d::a6 |
| X-Trace | 1328323649 news.xs4all.nl 6951 [2001:888:2000:d::a6]:55064 |
| X-Complaints-To | abuse@xs4all.nl |
| Xref | x330-a1.tempe.blueboxinc.net comp.lang.python:19852 |
Show key headers only | View raw
On Fri, Feb 3, 2012 at 4:27 PM, Antti J Ylikoski <antti.ylikoski@tkk.fi> wrote: > > In Python textbooks that I have read, it is usually not mentioned that > we can very easily program Common LISP-style closures with Python. It > is done as follows: > > ------------------------------------- > > # Make a Common LISP-like closure with Python. > # > # Antti J Ylikoski 02-03-2012. > > def f1(): > n = 0 > def f2(): > nonlocal n > n += 1 > return n > return f2 <snip> > i. e. we can have several functions with private local states which > are kept between function calls, in other words we can have Common > LISP-like closures. Out of curiosity, what would be non-Common-Lisp-style closures? Cheers, Chris
Back to comp.lang.python | Previous | Next — Previous in thread | Next in thread | Find similar | Unroll thread
Common LISP-style closures with Python Antti J Ylikoski <antti.ylikoski@tkk.fi> - 2012-02-04 02:27 +0200
Re: Common LISP-style closures with Python Chris Rebert <clp2@rebertia.com> - 2012-02-03 18:47 -0800
Re: Common LISP-style closures with Python Antti J Ylikoski <antti.ylikoski@tkk.fi> - 2012-02-04 12:14 +0200
Re: Common LISP-style closures with Python Antti J Ylikoski <antti.ylikoski@tkk.fi> - 2012-02-04 12:23 +0200
Re: Common LISP-style closures with Python Arnaud Delobelle <arnodel@gmail.com> - 2012-02-04 10:58 +0000
Re: Common LISP-style closures with Python Antti J Ylikoski <antti.ylikoski@tkk.fi> - 2012-02-04 15:09 +0200
Re: Common LISP-style closures with Python Tomasz Rola <rtomek@ceti.pl> - 2012-02-04 18:42 +0100
Re: Common LISP-style closures with Python Devin Jeanpierre <jeanpierreda@gmail.com> - 2012-02-04 17:52 -0500
Re: Common LISP-style closures with Python John O'Hagan <research@johnohagan.com> - 2012-02-05 12:31 +1100
Re: Common LISP-style closures with Python Antti J Ylikoski <antti.ylikoski@tkk.fi> - 2012-02-05 06:19 +0200
Re: Common LISP-style closures with Python Ian Kelly <ian.g.kelly@gmail.com> - 2012-02-05 13:58 -0700
Re: Common LISP-style closures with Python Antti J Ylikoski <antti.ylikoski@tkk.fi> - 2012-02-06 07:55 +0200
Re: Common LISP-style closures with Python Rick Johnson <rantingrickjohnson@gmail.com> - 2012-02-05 15:29 -0800
Re: Common LISP-style closures with Python John Nagle <nagle@animats.com> - 2012-02-09 22:26 -0800
Re: Common LISP-style closures with Python 88888 Dihedral <dihedral88888@googlemail.com> - 2012-02-09 23:55 -0800
csiph-web