Persist objects in a LIST
Vincent Vande Vyvre
vincent.vande.vyvre at telenet.be
Sat Nov 14 11:33:59 EST 2015
Le 14/11/2015 16:39, Dennis Lee Bieber a écrit :
> On Sat, 14 Nov 2015 07:02:41 -0800 (PST), John Zhao <johnzzhao at gmail.com>
> declaimed the following:
>
>> I found a solution. replace bDict.clear() with bDict = {}
>>
> Which is creating a second, empty, dictionary and binding the name
> "bDict" to that new one.
>
> If all you want is to get rid of the name
>
> del bDict
>
> should suffice.
Not exactly.
>>> l = []
>>> d = {'key': 'val'}
>>> l.append(d)
>>> l
[{'key': 'val'}]
>>> del d
>>> l
[{'key': 'val'}]
>>> del l[0]
>>> l
[]
>>>
Vince
More information about the Python-list
mailing list