I wirte a simple as following.
Could someone can tell me why the answer is different Buf1 and Buf2 ??
Thank for you help.
Could someone can tell me why the answer is different Buf1 and Buf2 ??
Thank for you help.
def fList_Test(pBuf, pX): pBuf.clear() _bufX = [] if pX == 0: _bufX = ['a1', 'a2'] elif pX == 1: _bufX = ['b1', 'b2'] else: _bufX = ['c1', 'c2'] pBuf.append(_bufX) Buf1 = [] Buf2 = [] Buf_T = [] for x in range(3): _bufX = [] fList_Test(Buf_T, x) Buf1.append(Buf_T) fList_Test(_bufX, x) Buf2.append(_bufX) print (Buf1) print (Buf2)output:
Output:[[['c1', 'c2']], [['c1', 'c2']], [['c1', 'c2']]]
[[['a1', 'a2']], [['b1', 'b2']], [['c1', 'c2']]]