0

Python 3.7

Why this:

a,b,c = [], [], []
print(a is b, b is c)

is different than this:

a,b,c = ([],) * 3
print(a is b, b is c)
  • 1
    In the first case you create three list objects: `[], [], []`. In the second case you only create one list object: `[]`. – deceze Jun 23 '20 at 13:15
  • 3
    `[], [], []` creates 3 independent list objects, `([],) * 3` copies the reference to the same list object 3 times. – jfaccioni Jun 23 '20 at 13:15

0 Answers0