This issue tracker has been migrated to GitHub, and is currently read-only.
For more information, see the GitHub FAQs in the Python's Developer Guide.

classification
Title: Cannot correctly concatenate nested list that contains more than ~45 entries with other nested lists.
Type: behavior Stage: resolved
Components: Versions: Python 3.5
process
Status: closed Resolution: not a bug
Dependencies: Superseder:
Assigned To: Nosy List: Domenico Barbieri, josh.r, steven.daprano
Priority: normal Keywords:

Created on 2019-02-26 08:59 by Domenico Barbieri, last changed 2022-04-11 14:59 by admin. This issue is now closed.

Messages (3)
msg336634 - (view) Author: Domenico Barbieri (Domenico Barbieri) Date: 2019-02-26 08:59
Here is an example of what happens:

>>> x = [["a", "b", ... , "BZ"]]
>>> y = [[], [1,2,3,4,5, ... , 99]]
>>> y[0] = x[0]
>>> print(y[0])
>>> ["a", "b", "c", ... , "BZ", [1,2,3,4,5, ... , 99]]
msg336635 - (view) Author: Steven D'Aprano (steven.daprano) * (Python committer) Date: 2019-02-26 09:21
I cannot reproduce the behaviour you show.

First problem: ``...`` is a legal Python object, Ellipsis, so your example code literally means:

# x = [["a", "b", ... , "BZ"]]

x is a list containing one sublist, which contains exactly four objects.

So when I run your code as you write it, I get:

py> x = [["a", "b", ... , "BZ"]]
py> y = [[], [1,2,3,4,5, ... , 99]]
py> y[0] = x[0]
py> print(y[0])
['a', 'b', Ellipsis, 'BZ']


which is exactly what I expect.

If we use more than 45 entries, as you suggest, I still cannot reproduce your bug report:


py> x = [ list(range(0, 100)) ]
py> y = [ [], list(range(1000, 1200)) ]
py> assert len(x[0]) > 45
py> assert len(y[1]) > 45
py> y[0] = x[0]
py> print(y[0])
[0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30, 31, 32, 33, 34, 35, 36, 37, 38, 39, 40, 41, 42, 43, 44, 45, 46, 47, 48, 49, 50, 51, 52, 53, 54, 55, 56, 57, 58, 59, 60, 61, 62, 63, 64, 65, 66, 67, 68, 69, 70, 71, 72, 73, 74, 75, 76, 77, 78, 79, 80, 81, 82, 83, 84, 85, 86, 87, 88, 89, 90, 91, 92, 93, 94, 95, 96, 97, 98, 99]

which is exactly the behaviour I expect.


The above is using Python 3.5.


I suggest you start from a fresh interpreter session and show precisely what steps needed to reproduce the behaviour you are seeing, and show the behaviour you expect. It might help to read this:

http://www.sscce.org/
msg336707 - (view) Author: Josh Rosenberg (josh.r) * (Python triager) Date: 2019-02-26 19:19
Agreed, I cannot reproduce this (online link showing behavior): https://tio.run/##K6gsycjPM/7/v0LBViE6WilRSUdBKQlI6OnpKQCZTlFKsbFclWDJWB2FaEMdIx1jHRMdU5gKS0uQfLRBLFBJBZDiKijKzCvRAIlocv3/DwA

My guess is the code is subtly different, e.g. replacing:

>>> y[0] = x[0]
>>> print(y[0])

with:

>>> y[:1] = x[0]
>>> print(y)

would get roughly what the OP is seeing (and it would be the correct/expected result in that case). Either way, not a bug.
History
Date User Action Args
2022-04-11 14:59:11adminsetgithub: 80299
2019-02-26 19:19:11josh.rsetstatus: open -> closed

nosy: + josh.r
messages: + msg336707

resolution: not a bug
stage: resolved
2019-02-26 09:21:25steven.dapranosetnosy: + steven.daprano
messages: + msg336635
2019-02-26 08:59:27Domenico Barbiericreate