New submission from wh1te r4bb1t <wh1te.r4b...@protonmail.com>:

Here is a code highlighting a very strange behavior. This has been noticed in  
python 3.7, 3.8 and 3.9.0a2


def function(input_list, a='x'):
    [input_list[i].append(a) for i in range(len(input_list))]
    return input_list

list1 = [[0], [0], [0]]
list2 = [[0]] * 3

list1 == list2   # return True

function(list1)  # return [[0, 'x'], [0, 'x'], [0, 'x']]
function(list2)  # return [[0, 'x', 'x', 'x'], [0, 'x', 'x', 'x'], [0, 'x', 
'x', 'x']]

list1 == list2   # return false

----------
messages: 360351
nosy: wh1te r4bb1t
priority: normal
severity: normal
status: open
title: Objects equal (assertEqual return True) but behave differently
type: behavior
versions: Python 3.8

_______________________________________
Python tracker <rep...@bugs.python.org>
<https://bugs.python.org/issue39403>
_______________________________________
_______________________________________________
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com

Reply via email to