Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > comp.lang.python > #88845

Re: Generarl programming question.

From Thomas 'PointedEars' Lahn <PointedEars@web.de>
Newsgroups comp.lang.python
Subject Re: Generarl programming question.
Date 2015-04-12 00:05 +0200
Organization PointedEars Software (PES)
Message-ID <4867215.Po4C3FaEzt@PointedEars.de> (permalink)
References (1 earlier) <mailman.222.1428765309.12925.python-list@python.org> <12030326.cc9aoE7jz1@PointedEars.de> <mailman.227.1428778121.12925.python-list@python.org> <3458425.12qjem4LOE@PointedEars.de> <mailman.233.1428786783.12925.python-list@python.org>

Show all headers | View raw


Terry Reedy wrote:

> On 4/11/2015 3:19 PM, Thomas 'PointedEars' Lahn wrote:
>> Terry Reedy wrote:
>>> What Chris is describing is one local namespace (sheet of paper) per
>>> function *call*.
>> I *know* what he is describing: the *call* stack.
> 
> My comment above was directed not at you specifically but at the OP,
> Jonas, […]

ACK

>> The variable $bar then keeps its last value for subsequent calls of
>> foo().
> 
> In Python, one can do something similar with attributes, except that
> attributes are easily accessible from outside the function.

AISB.  Python’s “attributes” are named “properties” elsewhere.

> Mutable defaults probably come closer.
> 
> def doubler(_val=[1])"
>    _val[0] *= 2
>    return _val[0]
> 
> print(doubler(), doubler(), doubler())
> # 2 4 8

Fascinating.  Thanks.

-- 
PointedEars

Twitter: @PointedEars2
Please do not cc me. / Bitte keine Kopien per E-Mail.

Back to comp.lang.python | Previous | NextPrevious in thread | Next in thread | Find similar | Unroll thread


Thread

Generarl programming question. jonas.thornvall@gmail.com - 2015-04-11 08:00 -0700
  Re: Generarl programming question. Chris Angelico <rosuav@gmail.com> - 2015-04-12 01:15 +1000
    Re: Generarl programming question. jonas.thornvall@gmail.com - 2015-04-11 08:22 -0700
      Re: Generarl programming question. Chris Angelico <rosuav@gmail.com> - 2015-04-12 01:28 +1000
    Re: Generarl programming question. Thomas 'PointedEars' Lahn <PointedEars@web.de> - 2015-04-11 18:23 +0200
      Re: Generarl programming question. Terry Reedy <tjreedy@udel.edu> - 2015-04-11 14:47 -0400
        Re: Generarl programming question. Thomas 'PointedEars' Lahn <PointedEars@web.de> - 2015-04-11 21:19 +0200
          Re: Generarl programming question. Terry Reedy <tjreedy@udel.edu> - 2015-04-11 17:12 -0400
            Re: Generarl programming question. Thomas 'PointedEars' Lahn <PointedEars@web.de> - 2015-04-12 00:05 +0200
              Re: Generarl programming question. Steven D'Aprano <steve+comp.lang.python@pearwood.info> - 2015-04-12 15:04 +1000
  Re: Generarl programming question. Steven D'Aprano <steve+comp.lang.python@pearwood.info> - 2015-04-12 01:25 +1000
    Re: Generarl programming question. jonas.thornvall@gmail.com - 2015-04-11 08:36 -0700

csiph-web