Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > Python > Re: Question about weakref

Reply
Thread Tools

Re: Question about weakref

 
 
Frank Millman
Guest
Posts: n/a
 
      07-05-2012
On 05/07/2012 10:46, Dieter Maurer wrote:
> Frank Millman<(E-Mail Removed)> 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

 
Reply With Quote
 
 
 
Reply

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
Re: Question about weakref Ian Kelly Python 0 07-06-2012 05:48 PM
Re: Question about weakref Frank Millman Python 0 07-06-2012 07:00 AM
Re: Question about weakref Dieter Maurer Python 0 07-05-2012 05:47 PM
Re: Question about weakref Dieter Maurer Python 0 07-05-2012 08:46 AM
Question about weakref Frank Millman Python 0 07-04-2012 01:46 PM



Advertisments