Nov-24-2017, 02:46 AM
(Nov-24-2017, 01:50 AM)Skaperen Wrote: but i was afraid of doing a = b = c = {} out of fear that a, b, and c would all be referencing the same dictionaryIt would dot that:
>>> a = b = c = {} >>> id(a) 8350192 >>> id(b) 8350192 >>> id(c) 8350192Easy fix:
>>> a, b, c = [{} for i in range(3)] >>> id(a) 8358720 >>> id(b) 52826352 >>> id(c) 8358672 >>> help(id) Help on built-in function id in module builtins: id(obj, /) Return the identity of an object. This is guaranteed to be unique among simultaneously existing objects. (CPython uses the object's memory address.)