kj wrote:

To clarify, this comes from my reading of Fredrik Lundh's pages
"Python Objects" (http://effbot.org/zone/python-objects.htm) and
"Call By Object" (http://effbot.org/zone/call-by-object.htm).
[snip]
[END OF LENGTHY QUOTE]

Therefore, extending just a bit beyond Lundh's explanation, if we
did:

name = []
name.append(1)
name[0] = 3

...the second assignment would amount to a method call on the object
called 'name', an operation of a very different nature (according
to Lundh) from the first assignment, which is a modification of a
namespace.

I disagree. Assignment creates an association. Modification of a namespace, when implemented, amounts to a method call on the concrete object, whether a Python object or not, that implements the abstraction of a namespace. At module scope,
  name = ob
is the same as
  globals()['name']=ob
Within a class statement, substitute '<class-dict>' for 'globals'
Within functions, CPython uses an internal array, so
  name = ob
becomes
  <locals_array>[name-number] = ob

Or, to put it another way, Python dicts and lists are, considered abstractly, associations also, just like namespaces. Dicts are more general than namespaces, sequences are 'number-spaces' instead of name-spaces.

Terry Jan Reedy

--
http://mail.python.org/mailman/listinfo/python-list

Reply via email to