Я наткнулся на неожиданное поведение в Python 3.12.6 во время выполнения назначения среза. < /p>
Вот минимальный пример: < /p>
l3 = [2, 3, 4, 5]
l3[::1] = [1, 3]
print(l3)
Expected:
Since l3[::1] selects 4 elements ([2, 3, 4, 5]) and [1, 3] only provides 2 replacement values, I expected:
ValueError: attempt to assign sequence of size 2 to extended slice of size 4
Actual in Python 3.12.6:
No error is raised, and the output is:
[1, 3]
System Info:
Python Version: 3.12.6
Implementation: CPython
OS: Windows 11
Question:
Has the behavior of slice assignment changed in Python 3.12.6, or is this an unintended bug? If it's a bug, should it be reported on the Python issue tracker?
Подробнее здесь: https://stackoverflow.com/questions/796 ... h-mismatch
Почему Python 3.12.6 не повышает valueError при несоответствии с разрезом задания? ⇐ Python
-
- Похожие темы
- Ответы
- Просмотры
- Последнее сообщение
-
-
Исправление предупреждений о несоответствии «Sendable» для ImageResource в Swift 5.10.
Anonymous » » в форуме IOS - 0 Ответы
- 16 Просмотры
-
Последнее сообщение Anonymous
-