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


Groups > comp.lang.python > #25892

Re: What's wrong with this code?

From Emile van Sebille <emile@fenx.com>
Subject Re: What's wrong with this code?
Date 2012-07-23 08:36 -0700
References <CAMugt-pRmdy5M_18rbGC13-6_aqVOCUHYX4-C-XaPWKh+dYRtg@mail.gmail.com>
Newsgroups comp.lang.python
Message-ID <mailman.2483.1343057664.4697.python-list@python.org> (permalink)

Show all headers | View raw


On 7/23/2012 7:50 AM Stone Li said...
> 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

This prints the first None,None

>     c = 1
>     d = 2
>     print e,f

And nothing has happened to e or f, so this is the second None,None

Why do you expect 1,2?

Emile



>     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 | Next | Find similar | Unroll thread


Thread

Re: What's wrong with this code? Emile van Sebille <emile@fenx.com> - 2012-07-23 08:36 -0700

csiph-web