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


Groups > comp.lang.python > #86251

Re: list storing variables

From Marko Rauhamaa <marko@pacujo.net>
Newsgroups comp.lang.python
Subject Re: list storing variables
Date 2015-02-23 20:22 +0200
Organization A noiseless patient Spider
Message-ID <8761ascwt4.fsf@elektro.pacujo.net> (permalink)
References <54eb2357$0$3011$426a74cc@news.free.fr> <cl16ncF4a8mU1@mid.individual.net>

Show all headers | View raw


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

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