[Python-Dev] Namespaces (original) (raw)
Guido van Rossum guido@python.org
Sat, 06 Apr 2002 10:13:17 -0500
- Previous message: [Python-Dev] Namespaces
- Next message: [Python-Dev] Namespaces
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]
> A = 1 binds 1 to the name "A" > > A.B = 1 calls A.setattr("B", 1) > > A["B"] = 1 calls A.setitem("B", 1) > > it's pretty clear that the first form differs from the others, > but what's the difference between the second and the third > form? or are all three name binding operations?
I don't know if it matters for your explanation, but the big difference between A.B and A["B"] is that in the latter, A is the namespace, while in the former, A has a namespace (usually, but not always called A.dict). These namespaces are distinct, otherwise you'd have trouble keeping track of the difference between d["clear"] and d.clear...
--Guido van Rossum (home page: http://www.python.org/~guido/)
- Previous message: [Python-Dev] Namespaces
- Next message: [Python-Dev] Namespaces
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]