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


Groups > comp.lang.python > #25883

What's wrong with this code?

Date 2012-07-23 22:50 +0800
Subject What's wrong with this code?
From Stone Li <viewfromoffice@gmail.com>
Newsgroups comp.lang.python
Message-ID <mailman.2478.1343055006.4697.python-list@python.org> (permalink)

Show all headers | View raw


[Multipart message — attachments visible in raw view] - view raw

I'm totally confused by this code:

Code:

> a = None
> b = None
> c = None
> d = None
> x = [[a,b],
>      [c,d]]
> e,f = x[1]
> print e,f
> c = 1
> d = 2
> print e,f
> e = 1
> f = 2
> print c,d
>
> Output:

None None
> None None
> 1 2
>


I'm expecting the code as:

> None None
> 1 2
> 1 2
>
>

What's wrong?
And this question made my GUI program totally out of control.
Thanks[?]

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


Thread

What's wrong with this code? Stone Li <viewfromoffice@gmail.com> - 2012-07-23 22:50 +0800
  Re: What's wrong with this code? Andrew Cooper <amc96@cam.ac.uk> - 2012-07-24 02:19 +0100
    Re: What's wrong with this code? Mark Lawrence <breamoreboy@yahoo.co.uk> - 2012-07-24 07:23 +0100
    Re: What's wrong with this code? Devin Jeanpierre <jeanpierreda@gmail.com> - 2012-07-24 03:38 -0400
    Re: What's wrong with this code? Ian Kelly <ian.g.kelly@gmail.com> - 2012-07-24 02:26 -0600
  Re: What's wrong with this code? Ulrich Eckhardt <ulrich.eckhardt@dominolaser.com> - 2012-07-24 09:47 +0200
    Re: What's wrong with this code? Chris Angelico <rosuav@gmail.com> - 2012-07-24 18:24 +1000
      Re: What's wrong with this code? Ulrich Eckhardt <ulrich.eckhardt@dominolaser.com> - 2012-07-24 12:05 +0200
    Re: What's wrong with this code? Steven D'Aprano <steve+comp.lang.python@pearwood.info> - 2012-07-24 08:26 +0000
    Re: What's wrong with this code? Thomas Rachel <nutznetz-0c1b6768-bfa9-48d5-a470-7603bd3aa915@spamschutz.glglgl.de> - 2012-07-24 11:34 +0200
  Re: What's wrong with this code? Thomas Rachel <nutznetz-0c1b6768-bfa9-48d5-a470-7603bd3aa915@spamschutz.glglgl.de> - 2012-07-24 10:34 +0200

csiph-web