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


Groups > comp.lang.python > #86253

Re: list storing variables

Path csiph.com!usenet.pasdenom.info!news.redatomik.org!nntpfeed.proxad.net!proxad.net!feeder1-1.proxad.net!217.188.199.168.MISMATCH!takemy.news.telefonica.de!telefonica.de!newsfeed.xs4all.nl!newsfeed3a.news.xs4all.nl!xs4all!newsgate.cistron.nl!newsgate.news.xs4all.nl!post.news.xs4all.nl!not-for-mail
Return-Path <python-python-list@m.gmane.org>
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; 'python.': 0.02; 'explicitly': 0.05; 'assign': 0.07; '#include': 0.09; 'main()': 0.09; 'mentions': 0.09; 'objects,': 0.09; 'received:80.91': 0.09; 'received:80.91.229': 0.09; 'received:gmane.org': 0.09; 'received:list': 0.09; 'variables.': 0.09; 'python': 0.11; '[2,': 0.16; 'assumptions': 0.16; 'operator.': 0.16; 'received:80.91.229.3': 0.16; 'received:dip0.t-ipconnect.de': 0.16; 'received:plane.gmane.org': 0.16; 'received:t-ipconnect.de': 0.16; 'wrote:': 0.18; 'pointed': 0.19; '>>>': 0.22; 'header:User- Agent:1': 0.23; 'looks': 0.24; 'shown': 0.26; 'header:X -Complaints-To:1': 0.27; "doesn't": 0.30; 'subject:list': 0.30; 'gcc': 0.31; 'trouble': 0.34; 'objects': 0.35; 'but': 0.35; 'similar': 0.36; 'to:addr:python-list': 0.38; 'to:addr:python.org': 0.39; 'enough': 0.39; 'received:org': 0.40; 'days': 0.60; 'ago.': 0.61; 'more': 0.64; 'different': 0.65; 'below:': 0.68; 'behavior': 0.77; 'analog': 0.84; 'confusion.': 0.84; 'implications': 0.84; 'lot,': 0.93
X-Injected-Via-Gmane http://gmane.org/
To python-list@python.org
From Peter Otten <__peter__@web.de>
Subject Re: list storing variables
Date Mon, 23 Feb 2015 19:41:23 +0100
Organization None
References <54eb2357$0$3011$426a74cc@news.free.fr> <cl16ncF4a8mU1@mid.individual.net> <8761ascwt4.fsf@elektro.pacujo.net>
Mime-Version 1.0
Content-Type text/plain; charset="ISO-8859-1"
Content-Transfer-Encoding 7Bit
X-Gmane-NNTP-Posting-Host p57bd9e67.dip0.t-ipconnect.de
User-Agent KNode/4.13.3
X-BeenThere python-list@python.org
X-Mailman-Version 2.1.15
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>
Newsgroups comp.lang.python
Message-ID <mailman.19094.1424716896.18130.python-list@python.org> (permalink)
Lines 67
NNTP-Posting-Host 2001:888:2000:d::a6
X-Trace 1424716896 news.xs4all.nl 2962 [2001:888:2000:d::a6]:41486
X-Complaints-To abuse@xs4all.nl
Xref csiph.com comp.lang.python:86253

Show key headers only | View raw


Marko Rauhamaa wrote:

> Peter Pearson <pkpearson@nowhere.invalid>:
> 
>>>>>> a = 2; b = 5
>>>>>> Li = [a, b]
>>>>>> Li
>>> [2, 5]
>>>>>> a=3
>>>>>> Li
>>> [2, 5]
>>
>> [...]
>>
>> The word "variable" brings implications and assumptions that get
>> people into trouble in Python.  Python doesn't have variables.
>> It has objects, and you can assign names to objects -- like sticky
>> notes, as someone in this newsgroup helpfully pointed out long ago.
>>
>> This way of thinking is significantly different from the familiar
>> "variable" mind-set of C, but looks similar enough to produce some
>> confusion.  For me, the sticky-note analogy helped a lot, and in a
>> few days many things made more sense.
> 
> It's no different in C:
> 
>    #include <stdio.h>
> 
>    int main()
>    {
>       int a = 2, b = 5;
>       int Li[2] = { a, b };
>       printf("%d %d\n", Li[0], Li[1]);
>       a = 3;
>       printf("%d %d\n", Li[0], Li[1]);
>       return 0;
>    }
> 
> Outputs:
> 
>    2 5
>    2 5
> 
> 
> Marko

The OP explicitly mentions the & operator. There's no python analog to that 
and the behavior shown below:

$ cat pointers.c
#include <stdio.h>

int main()
{
  int a = 2, b = 5;
  int * Li[2] = { &a, &b };
  printf("%d %d\n", *Li[0], *Li[1]);
  a = 3;
  printf("%d %d\n", *Li[0], *Li[1]);
  return 0;
}
$ gcc pointers.c
$ ./a.out 
2 5
3 5

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


Thread

list storing variables "ast" <nomail@invalid.com> - 2015-02-23 13:55 +0100
  Re: list storing variables Dave Angel <davea@davea.name> - 2015-02-23 08:24 -0500
  Re: list storing variables Marko Rauhamaa <marko@pacujo.net> - 2015-02-23 15:49 +0200
  Re: list storing variables Peter Pearson <pkpearson@nowhere.invalid> - 2015-02-23 17:35 +0000
    Re: list storing variables Marko Rauhamaa <marko@pacujo.net> - 2015-02-23 20:22 +0200
      Re: list storing variables Peter Otten <__peter__@web.de> - 2015-02-23 19:41 +0100
        Re: list storing variables Marko Rauhamaa <marko@pacujo.net> - 2015-02-23 21:06 +0200
          Re: list storing variables Chris Angelico <rosuav@gmail.com> - 2015-02-24 06:17 +1100
            Re: list storing variables Marko Rauhamaa <marko@pacujo.net> - 2015-02-23 22:25 +0200
          Re: list storing variables Ian Kelly <ian.g.kelly@gmail.com> - 2015-02-23 12:29 -0700
            Re: list storing variables Marko Rauhamaa <marko@pacujo.net> - 2015-02-23 22:38 +0200
  Re: list storing variables Ben Finney <ben+python@benfinney.id.au> - 2015-02-24 09:03 +1100
    Re: list storing variables Steven D'Aprano <steve+comp.lang.python@pearwood.info> - 2015-02-24 13:24 +1100
      Re: list storing variables Marko Rauhamaa <marko@pacujo.net> - 2015-02-24 10:18 +0200

csiph-web