Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
Groups > comp.lang.python > #99861
| Path | csiph.com!news.mixmin.net!weretis.net!feeder1.news.weretis.net!feeder.erje.net!1.eu.feeder.erje.net!fu-berlin.de!uni-berlin.de!not-for-mail |
|---|---|
| From | Antoon Pardon <antoon.pardon@rece.vub.ac.be> |
| Newsgroups | comp.lang.python |
| Subject | Re: static variables |
| Date | Wed, 02 Dec 2015 10:47:15 +0100 |
| Lines | 37 |
| Message-ID | <mailman.113.1449049639.14615.python-list@python.org> (permalink) |
| References | <n3i06o$9ot$1@news2.informatik.uni-stuttgart.de> <n3ibkd$nl0$1@dont-email.me> <565cf163$0$1612$c3e8da3$5496439d@news.astraweb.com> <n3jljn$os2$1@news2.informatik.uni-stuttgart.de> <n3joag$v4e$1@dont-email.me> <565e4329$0$1612$c3e8da3$5496439d@news.astraweb.com> <mailman.97.1449019041.14615.python-list@python.org> <565e4861$0$1587$c3e8da3$5496439d@news.astraweb.com> <565EAA1D.501@rece.vub.ac.be> <CAPTjJmoUfv5H4NzXY4xB3PGDD7eyZ2ws-Ghy6smJW7Ockn+5vQ@mail.gmail.com> |
| Mime-Version | 1.0 |
| Content-Type | text/plain; charset=utf-8 |
| Content-Transfer-Encoding | 7bit |
| X-Trace | news.uni-berlin.de Wls7iiPE3VAfaezrYsvLgw4xOCK3VOp37JZTZ90NeiCw== |
| Return-Path | <antoon.pardon@rece.vub.ac.be> |
| X-Original-To | python-list@python.org |
| Delivered-To | python-list@mail.python.org |
| X-Spam-Status | OK 0.001 |
| X-Spam-Evidence | '*H*': 1.00; '*S*': 0.00; 'static': 0.03; 'args': 0.04; 'received:134': 0.05; 'attributes': 0.07; 'executable': 0.07; 'python': 0.10; 'python.': 0.11; 'def': 0.13; 'wed,': 0.15; 'argument': 0.15; 'declaration': 0.16; 'defaults,': 0.16; 'foo()': 0.16; 'foo():': 0.16; 'received:ac.be': 0.16; 'received:io': 0.16; 'received:psf.io': 0.16; 'somewhere.': 0.16; 'statement.': 0.16; 'wrote:': 0.16; 'variable': 0.18; 'changes': 0.20; '2015': 0.20; 'otherwise,': 0.20; 'skip:" 30': 0.20; 'meant': 0.22; 'function,': 0.22; 'visible': 0.22; 'code.': 0.23; 'defined': 0.23; 'dec': 0.23; 'header:In-Reply-To:1': 0.24; 'header:User-Agent:1': 0.26; 'chris': 0.26; 'function': 0.28; 'initialized': 0.29; 'too.': 0.30; 'received:be': 0.30; 'probably': 0.31; 'statement': 0.32; 'lets': 0.33; 'could': 0.35; 'done': 0.35; 'something': 0.35; 'instead': 0.36; '(and': 0.36; 'keyword': 0.36; 'totally': 0.36; 'to:addr:python-list': 0.36; 'pm,': 0.36; 'subject:: ': 0.37; 'being': 0.37; 'goes': 0.39; 'to:addr:python.org': 0.40; 'where': 0.40; 'your': 0.60; 'body': 0.61; 'default': 0.61; 'more': 0.63; 'talking': 0.67; 'obvious': 0.76; 'angelico:': 0.84; 'pardon': 0.84; 'schreef': 0.84; 'write:': 0.91; 'have.': 0.93 |
| X-IronPort-Anti-Spam-Filtered | true |
| X-IronPort-Anti-Spam-Result | AusFAHK9XlaGuA9G/2dsb2JhbABehFYBJcADhg4CghsBAQEBAQGFPwEBAQMBI1UGCwsYAgIFFgsCAgkDAgECAUUTBgICF4gMCK1zjH2EBQEBCAIhgQGFU4R9hSeCToFEBZZcjTuBW4c2j2eDcmOEBXEBhW4BAQE |
| User-Agent | Mozilla/5.0 (X11; Linux i686; rv:31.0) Gecko/20100101 Icedove/31.8.0 |
| In-Reply-To | <CAPTjJmoUfv5H4NzXY4xB3PGDD7eyZ2ws-Ghy6smJW7Ockn+5vQ@mail.gmail.com> |
| X-BeenThere | python-list@python.org |
| X-Mailman-Version | 2.1.20+ |
| Precedence | list |
| List-Id | General discussion list for the Python programming language <python-list.python.org> |
| List-Unsubscribe | <https://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 | <https://mail.python.org/mailman/listinfo/python-list>, <mailto:python-list-request@python.org?subject=subscribe> |
| Xref | csiph.com comp.lang.python:99861 |
Show key headers only | View raw
Op 02-12-15 om 10:23 schreef Chris Angelico: > On Wed, Dec 2, 2015 at 7:21 PM, Antoon Pardon > <antoon.pardon@rece.vub.ac.be> wrote: >> I think python is unsuited for an obvious solution for static locals. >> Because you need to initialise your static variable somewhere. If you >> initialise whithin the body of your function, you will have a statement >> that is essentialy a declaration instead of an executable statement. >> Which goes totally against the dynamic nature op python. > It ought to be initialized at the same time the function is defined - > just like argument defaults, only without them being visible as > arguments. I am not talking about the time. That could be done with something declarative too. I am talking about where to put in the code. > If Python had a keyword that meant > "currently-executing-function", that would work out well for > attributes (and might also make recursion more optimizable); > otherwise, default args are probably the cleanest way we have. No it wouldn't. Lets call that keyword cef. The fact that you can write: def foo(): cef.attr instead of def foo() foo.attr changes nothing about foo.attr being globally accessible. -- Antoon.
Back to comp.lang.python | Previous | Next — Previous in thread | Next in thread | Find similar | Unroll thread
static variables Ulli Horlacher <framstag@rus.uni-stuttgart.de> - 2015-11-30 17:15 +0000
Re: static variables Terry Reedy <tjreedy@udel.edu> - 2015-11-30 12:38 -0500
Re: static variables BartC <bc@freeuk.com> - 2015-11-30 20:32 +0000
Re: static variables Steven D'Aprano <steve@pearwood.info> - 2015-12-01 12:01 +1100
Re: static variables Ulli Horlacher <framstag@rus.uni-stuttgart.de> - 2015-12-01 08:26 +0000
Re: static variables Peter Otten <__peter__@web.de> - 2015-12-01 10:01 +0100
Re: static variables Grobu <snailcoder@retrosite.invalid> - 2015-12-01 10:15 +0100
Re: static variables Steven D'Aprano <steve@pearwood.info> - 2015-12-02 12:02 +1100
Re: static variables Erik <python@lucidity.plus.com> - 2015-12-02 01:16 +0000
Re: static variables Steven D'Aprano <steve@pearwood.info> - 2015-12-02 12:24 +1100
Re: static variables Antoon Pardon <antoon.pardon@rece.vub.ac.be> - 2015-12-02 09:21 +0100
Re: static variables Antoon Pardon <antoon.pardon@rece.vub.ac.be> - 2015-12-02 09:34 +0100
Re: static variables Steven D'Aprano <steve@pearwood.info> - 2015-12-02 21:22 +1100
Re: static variables Antoon Pardon <antoon.pardon@rece.vub.ac.be> - 2015-12-02 12:09 +0100
Re: static variables Steven D'Aprano <steve@pearwood.info> - 2015-12-03 00:11 +1100
Re: static variables Antoon Pardon <antoon.pardon@rece.vub.ac.be> - 2015-12-02 14:41 +0100
Re: static variables Mark Lawrence <breamoreboy@yahoo.co.uk> - 2015-12-02 13:48 +0000
Re: static variables Antoon Pardon <antoon.pardon@rece.vub.ac.be> - 2015-12-02 15:07 +0100
Re: static variables Ian Kelly <ian.g.kelly@gmail.com> - 2015-12-02 08:15 -0600
Re: static variables Mark Lawrence <breamoreboy@yahoo.co.uk> - 2015-12-02 14:31 +0000
Re: static variables Antoon Pardon <antoon.pardon@rece.vub.ac.be> - 2015-12-02 16:30 +0100
Re: static variables Ian Kelly <ian.g.kelly@gmail.com> - 2015-12-02 14:30 -0600
Re: static variables Antoon Pardon <antoon.pardon@rece.vub.ac.be> - 2015-12-03 10:06 +0100
Re: static variables Chris Angelico <rosuav@gmail.com> - 2015-12-02 20:23 +1100
Re: static variables Antoon Pardon <antoon.pardon@rece.vub.ac.be> - 2015-12-02 10:47 +0100
Re: static variables Marko Rauhamaa <marko@pacujo.net> - 2015-12-02 12:18 +0200
Re: static variables Antoon Pardon <antoon.pardon@rece.vub.ac.be> - 2015-12-02 11:56 +0100
Re: static variables Marko Rauhamaa <marko@pacujo.net> - 2015-12-02 13:30 +0200
Re: static variables Steven D'Aprano <steve@pearwood.info> - 2015-12-03 00:17 +1100
Re: static variables Wolfgang Maier <wolfgang.maier@biologie.uni-freiburg.de> - 2015-12-01 10:58 +0100
Re: static variables Ulli Horlacher <framstag@rus.uni-stuttgart.de> - 2015-12-01 11:47 +0000
csiph-web