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

Discussion in 'Python' started by John Nagle, Feb 25, 2007.

  1. John Nagle

    John Nagle Guest

    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
     
    John Nagle, Feb 25, 2007
    #1
    1. Advertising

  2. 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
     
    Gabriel Genellina, Feb 26, 2007
    #2
    1. Advertising

  3. John Nagle

    John Nagle Guest

    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
     
    John Nagle, Feb 26, 2007
    #3
    1. Advertising

Want to reply to this thread or ask your own question?

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. Ames Andreas (MPA/DF)

    weakref and thread safety (in python 2.1)

    Ames Andreas (MPA/DF), Jul 22, 2003, in forum: Python
    Replies:
    1
    Views:
    438
    Duncan Booth
    Jul 22, 2003
  2. William Trenker

    Using weakref with execfile?

    William Trenker, Dec 21, 2003, in forum: Python
    Replies:
    1
    Views:
    282
    Martin v. Loewis
    Dec 22, 2003
  3. ali

    what is the use of weakref?

    ali, Jan 30, 2004, in forum: Python
    Replies:
    2
    Views:
    287
    Duncan Booth
    Jan 30, 2004
  4. Walter Haslbeck

    problem with weakref.proxy

    Walter Haslbeck, Jan 31, 2004, in forum: Python
    Replies:
    5
    Views:
    544
    Walter Haslbeck
    Jan 31, 2004
  5. Nicholas Cole

    weakref.proxy behaviour in python 3.0

    Nicholas Cole, Aug 21, 2010, in forum: Python
    Replies:
    3
    Views:
    494
    Mark Dickinson
    Aug 21, 2010
Loading...

Share This Page