Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
Groups > comp.lang.python > #16717 > unrolled thread
| Started by | Yingjie Lan <lanyjie@yahoo.com> |
|---|---|
| First post | 2011-12-06 03:06 -0800 |
| Last post | 2011-12-06 03:06 -0800 |
| Articles | 1 — 1 participant |
Back to article view | Back to comp.lang.python
the deceptive continuous assignments Yingjie Lan <lanyjie@yahoo.com> - 2011-12-06 03:06 -0800
| From | Yingjie Lan <lanyjie@yahoo.com> |
|---|---|
| Date | 2011-12-06 03:06 -0800 |
| Subject | the deceptive continuous assignments |
| Message-ID | <mailman.3339.1323169726.27778.python-list@python.org> |
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 top | Article view | comp.lang.python
csiph-web