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


Groups > comp.lang.python > #16717

the deceptive continuous assignments

Path csiph.com!x330-a1.tempe.blueboxinc.net!usenet.pasdenom.info!weretis.net!feeder1.news.weretis.net!feeder.erje.net!newsfeed.xs4all.nl!newsfeed6.news.xs4all.nl!xs4all!newsgate.cistron.nl!newsgate.news.xs4all.nl!post.news.xs4all.nl!not-for-mail
Return-Path <lanyjie@yahoo.com>
X-Original-To python-list@python.org
Delivered-To python-list@mail.python.org
X-Spam-Status OK 0.007
X-Spam-Evidence '*H*': 0.99; '*S*': 0.00; 'attribute': 0.07; 'python': 0.08; 'to:name:python list': 0.09; 'thanks!': 0.14; "'int'": 0.16; 'error).': 0.16; 'from:addr:lanyjie': 0.16; 'from:name:yingjie lan': 0.16; 'received:124.205': 0.16; 'received:98.139.52.189': 0.16; 'reply-to:addr:lanyjie': 0.16; 'reply-to:name:yingjie lan': 0.16; 'yingjie': 0.16; '>>>': 0.18; '(which': 0.19; 'seems': 0.20; '(most': 0.21; 'traceback': 0.24; 'skip:= 10': 0.28; 'pass': 0.29; 'class': 0.29; 'hi,': 0.32; 'assigned': 0.32; 'object': 0.33; 'to:addr:python-list': 0.34; 'last):': 0.34; 'file': 0.36; 'but': 0.37; 'why': 0.39; 'to:addr:python.org': 0.40; 'further': 0.64; 'here': 0.65; 'received:98.139.52': 0.67; 'header:Reply-To:1': 0.71; 'deviate': 0.84
X-Yahoo-Newman-Property ymail-3
X-Yahoo-Newman-Id 737380.50639.bm@omp1027.mail.ac4.yahoo.com
DKIM-Signature v=1; a=rsa-sha256; c=relaxed/relaxed; d=yahoo.com; s=s1024; t=1323169564; bh=qnYUkKTiyQ2lCprr3EpDwR1iCiQnAtppO5TKOuwB/8I=; h=X-YMail-OSG:Received:X-Mailer:Message-ID:Date:From:Reply-To:Subject:To:MIME-Version:Content-Type:Content-Transfer-Encoding; b=2uCRy1bIc+Urt5VZtfkwb2fkqhiq56vPlgIgxq6bhG1jek1DNOuBalxslAnO6Vru6ZcHMiF2mh3x44d258+5/7wSYc+M+rlcrKoM9i6GhRsDukyxMWxtVq4g1gouC5BRWpbk2XUGv22gamBrWeIkmPqb0TAcE7AWDBmEWmx7URI=
DomainKey-Signature a=rsa-sha1; q=dns; c=nofws; s=s1024; d=yahoo.com; h=X-YMail-OSG:Received:X-Mailer:Message-ID:Date:From:Reply-To:Subject:To:MIME-Version:Content-Type:Content-Transfer-Encoding; b=A5Ecdua4Y8yA3Oz3C0XGHqphZx3iATT537qERR7PWyyDZSwJcFZT78QmWmoixtSk7LvPgAivKk3vBxHAvURco0YWdjrhe0tLaDbc7BVJwhBEUOXmDZjZ/DUj2Mq20+f1GCXH2EYEejXBJ8zUZZGvDwkTA4lggcUGW4L4ErhIScI=;
X-YMail-OSG x221QW0VM1lc4BojdhBNcUrynDS23No_U9mDf2wA5aqTjl9 t8ueM.CTudgM6CO2O6JrcZqIi66LeudR6vNciqKWwpIrKSdQa81TTU_jWqkf BAtOPCq3xQWSK19x8A2pU2BLAO1NwDLjUHei3HQQJwsihUGFhcMcpEW.3mjk XPI4lBJoEk7jH0gVhM_dCx2hTtJJxR99kDAqjJ2imoSJ2mJX5b7BTz76wuAm sbKhxzOpiiJKLr81zvbeWnrODr9miUt_a.W4K2kR6fXsVF0XrTDGTW3WHG88 wQ0V0GAyq6PF0rIR9KfVGlfAN.3EDNKFrijHGmLS5DMXAM8bClNSuYFoRq5H vp9FL5DlFQWDs7NSWPy5BwOgoL7GvSLPqEB6BAGWKcgapZPqJYRORJZPFrT2 Txog6vUSz68LvHxvZwBcUTRAORbRNMLufpP.FRX3y
X-Mailer YahooMailWebService/0.8.115.331698
Date Tue, 6 Dec 2011 03:06:04 -0800 (PST)
From Yingjie Lan <lanyjie@yahoo.com>
Subject the deceptive continuous assignments
To python list <python-list@python.org>
MIME-Version 1.0
Content-Type text/plain; charset=iso-8859-1
Content-Transfer-Encoding quoted-printable
X-BeenThere python-list@python.org
X-Mailman-Version 2.1.12
Precedence list
Reply-To Yingjie Lan <lanyjie@yahoo.com>
List-Id General discussion list for the Python programming language <python-list.python.org>
List-Unsubscribe <http://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 <http://mail.python.org/mailman/listinfo/python-list>, <mailto:python-list-request@python.org?subject=subscribe>
Newsgroups comp.lang.python
Message-ID <mailman.3339.1323169726.27778.python-list@python.org> (permalink)
Lines 10
NNTP-Posting-Host 2001:888:2000:d::a6
X-Trace 1323169726 news.xs4all.nl 6967 [2001:888:2000:d::a6]:45884
X-Complaints-To abuse@xs4all.nl
Xref x330-a1.tempe.blueboxinc.net comp.lang.python:16717

Show key headers only | View raw


Hi, I just figured out this with Python3.2 IDLE:

>>> class k: pass
>>> x=k()
>>> x.thing = 1
>>> x.thing
1
>>> x = x.thing = 1
Traceback (most recent call last):
  File "<pyshell#7>", line 1, in <module>
    x = x.thing = 1
AttributeError: 'int' object has no attribute 'thing'
>>> x
1
>>>

================
when I do x=x.thing=1, I thought it would
be like in C, 1 is first assigned to x.thing,
then it is further assigned to x.

But what seems to be going on here is
that 1 is first assigned to x, then
to x.thing (which causes an error).

Any reason why would Python deviate
from C in this regard?

Thanks!

Yingjie

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


Thread

the deceptive continuous assignments Yingjie Lan <lanyjie@yahoo.com> - 2011-12-06 03:06 -0800

csiph-web