Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > comp.lang.python > #36919

Re: cymbalic reference?

From Terry Reedy <tjreedy@udel.edu>
Subject Re: cymbalic reference?
Date 2013-01-16 19:30 -0500
References <20130115205604.178fa30eff8ae7155174d900@lavabit.com> <CAMuTYXjBo1bx6uDj3weSbZVK65yvVPBJETmJ5pmfneWuO=DyzQ@mail.gmail.com> <20130116130632.d0fa6835d87a92d04c286284@lavabit.com>
Newsgroups comp.lang.python
Message-ID <mailman.583.1358382627.2939.python-list@python.org> (permalink)

Show all headers | View raw


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

Back to comp.lang.python | Previous | Next | Find similar | Unroll thread


Thread

Re: cymbalic reference? Terry Reedy <tjreedy@udel.edu> - 2013-01-16 19:30 -0500

csiph-web