anything like C++ references?
Aahz
aahz at pythoncraft.com
Mon Jul 14 10:21:12 EDT 2003
In article <mailman.1058150840.26704.python-list at python.org>,
Ian Bicking <ianb at colorstudy.com> wrote:
>On Sun, 2003-07-13 at 20:32, Aahz wrote:
>> In article <mailman.1058126720.6756.python-list at python.org>,
>> Ian Bicking <ianb at colorstudy.com> wrote:
>>>
>>>(Admittedly, some confusion may occur because these very different
>>>operations use the same syntax:
>>>
>>> x = 10
>>> x[0] = 10
>>> obj.x = 10
>>>
>>>The second and third are entirely different from the first.)
>>
>> No, they aren't. They are precisely the same; they just have different
>> assignment targets.
>
>Sure they are different. The first is a primitive operation binding the
>variable x. The second gets x, and calls x.__setitem__(0, 10), and the
>third is equivalent to setattr(obj, 'x', 10).
>
>The first is primitive syntax. I suppose you could say that it could be
>reduced to operations on locals() and globals(), but I feel like that's
>a detail that is best not brought up ;) The local and global scope are
>not as flexible as other objects The other two are really just syntactic
>sugar.
You've got a good point, but I think my point is just as valid. Which
viewpoint is more appropriate depends on the circumstance.
--
Aahz (aahz at pythoncraft.com) <*> http://www.pythoncraft.com/
"Not everything in life has a clue in front of it...." --JMS
More information about the Python-list
mailing list