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


Groups > comp.lang.python > #24908 > unrolled thread

Re: Question about weakref

Started byFrank Millman <frank@chagford.com>
First post2012-07-05 13:21 +0200
Last post2012-07-05 13:21 +0200
Articles 1 — 1 participant

Back to article view | Back to comp.lang.python

This discussion starts older than the indexed window; earlier articles aren't shown. The article labeled Started by below is the oldest one visible, not the original post.


Contents

  Re: Question about weakref Frank Millman <frank@chagford.com> - 2012-07-05 13:21 +0200

#24908 — Re: Question about weakref

FromFrank Millman <frank@chagford.com>
Date2012-07-05 13:21 +0200
SubjectRe: Question about weakref
Message-ID<mailman.1821.1341487322.4697.python-list@python.org>
On 05/07/2012 10:46, Dieter Maurer wrote:
> Frank Millman<frank@chagford.com>  writes:
>
>> I have a situation where I thought using weakrefs would save me a bit
>> of effort.
>
> Instead of the low level "weakref", you might use a "WeakKeyDictionary".
>

Thanks, Dieter. I could do that.

In fact, a WeakSet suits my purposes better. I tested it with my 
original example, and it works correctly. It also saves me the step of 
deleting the weak reference once the original object is deleted, as it 
seems to do that automatically.

I just need to double-check that I would never have the same 
listener-object try to register itself with the publisher twice, as that 
would obviously fail with a Set, as it would with a Dict.

I would still like to know why weakref.proxy raised an exception. I have 
re-read the manual several times, and googled for similar problems, but 
am none the wiser. Naturally I feel a bit uneasy using a feature of the 
language which sometimes fails mysteriously, so if anyone has an 
explanation, I would really appreciate it.

Frank

[toc] | [standalone]


Back to top | Article view | comp.lang.python


csiph-web