cymbalic reference?

Terry Reedy tjreedy at udel.edu
Wed Jan 16 19:30:03 EST 2013


On 1/16/2013 4:06 PM, rh wrote:

> My final product uses your suggestions along with one from the other post.
> I like the idea of storing the class name as the key.  Then no call to globals()
> is needed.  But I still have to test how that object behaves when it's a key.
> i.e. Is it deeply bound? Shallow? Tight? Loose? Not sure which is the correct
> term!

The only effect on an object of making it a dict key is that it cannot 
disappear.

class C: pass
d = {C: 'C'}
del C
# The name 'C' can no longer be used to access the class
# However, the class cannot be deleted because it is in use
for c in d: print(c)

> So maybe I want {Abc:'http://example.com'} and o = s() instead.

Yes, as I suggested.

-- 
Terry Jan Reedy




More information about the Python-list mailing list