[IPython-dev] Getting InteractiveShell to clean up after itself

Robert Kern robert.kern at gmail.com
Wed Aug 26 16:45:36 EDT 2009


On 2009-08-26 13:40 PM, Fernando Perez wrote:

> 1. While I'm all for using more weakrefs, they are a subtle tool and I
> doubt we can get away with using them everywhere for everything.  I
> don't want to 'bet the farm' on that strategy, because we can easily
> find a situation where weakrefs don't work, we have way too much
> user-facing  state managemnet we must accomplish robustly and weakrefs
> may not be the tool for everything we need to do.

In [11]: from enthought.traits.api import HasTraits, WeakRef

In [12]: class A(HasTraits):
    ....:     b = WeakRef()
    ....:

In [14]: b = HasTraits()

In [15]: a = A(b=b)

In [16]: print a.b
<enthought.traits.has_traits.HasTraits object at 0x18a1cf0>

In [17]: del b

In [18]: print a.b
None


Just sayin'.

-- 
Robert Kern

"I have come to believe that the whole world is an enigma, a harmless enigma
  that is made terrible by our own mad attempt to interpret it as though it had
  an underlying truth."
   -- Umberto Eco




More information about the IPython-dev mailing list