On Wed, Aug 16, 2017 at 5:03 PM, Stefan Ram <[email protected]> wrote:
> Chris Angelico <[email protected]> writes:
>>objects exist independently of names
>
> When the object »Example()« loses its name below,
> it loses its existence.
>
> class Example(object):
> ... def __init__(self):
> ... print( 'initialized' )
> ... def __del__(self):
> ... print( 'deleted' )
> ...
>>>> a = Example()
> initialized
>>>> a = 2
> deleted
Try:
>>> class Example(object):
... def __init__(self):
... print('initialized')
... def __del__(self):
... print('deleted')
...
>>> a = Example()
initialized
>>> b = [a]
>>> a = 2
>>>
The object no longer has a name, but it still exists.
--
https://mail.python.org/mailman/listinfo/python-list