Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > Python > Weakref problem: no way to get original object from proxy object?

Reply
Thread Tools

Weakref problem: no way to get original object from proxy object?

 
 
John Nagle
Guest
Posts: n/a
 
      02-25-2007
Is there some way to get a strong ref to the original object back
from a weakref proxy object? I can't find any Python function to do this.
".ref()" doesn't work on proxy objects.

John Nagle
 
Reply With Quote
 
 
 
 
Gabriel Genellina
Guest
Posts: n/a
 
      02-26-2007
En Sun, 25 Feb 2007 19:07:38 -0300, John Nagle <>
escribió:

> Is there some way to get a strong ref to the original object back
> from a weakref proxy object? I can't find any Python function to do
> this.
> ".ref()" doesn't work on proxy objects.


Add a method to the original class that just returns self.

About your backref function: Yes, I usually use something like that, it's
annoying having to handle None always.

--
Gabriel Genellina

 
Reply With Quote
 
 
 
 
John Nagle
Guest
Posts: n/a
 
      02-26-2007
Gabriel Genellina wrote:
> En Sun, 25 Feb 2007 19:07:38 -0300, John Nagle <>
> escribió:
>
>> Is there some way to get a strong ref to the original object back
>> from a weakref proxy object? I can't find any Python function to do
>> this.
>> ".ref()" doesn't work on proxy objects.

>
>
> Add a method to the original class that just returns self.


Yes, that works. Thanks.

John Nagle
 
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
weakref.proxy behaviour in python 3.0 Nicholas Cole Python 3 08-21-2010 07:45 PM
problem with weakref.proxy Walter Haslbeck Python 5 01-31-2004 07:19 PM
what is the use of weakref? ali Python 2 01-30-2004 09:14 AM
Using weakref with execfile? William Trenker Python 1 12-22-2003 12:11 AM
weakref and thread safety (in python 2.1) Ames Andreas (MPA/DF) Python 1 07-22-2003 12:53 PM



Advertisments
 



1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57