[issue45179] List.sort ERROR

2021-09-12 Thread Steven D'Aprano


Steven D'Aprano  added the comment:

Wait, are you talking about the list appearing to be empty during the sort? 
That's expected behaviour and not a bug:

https://docs.python.org/3/library/stdtypes.html#list.sort

I'm going to close this issue as Not A Bug. If the problem is something else, 
please re-open it with:

- an explanation of what you think the bug is;

- why you think it is a bug;

- a simple test case;

- the output you expect;

- and the actual output.


It is not enough to give the actual output with no explanation for why you 
think it is wrong.

--
resolution:  -> not a bug
stage:  -> resolved
status: open -> closed

___
Python tracker 

___
___
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue45179] List.sort ERROR

2021-09-12 Thread Steven D'Aprano


Steven D'Aprano  added the comment:

Sorry, it is not clear what you think is the bug. What output do you expect?

When I run the code, F and G are correctly sorted.

--
nosy: +steven.daprano

___
Python tracker 

___
___
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue45179] List.sort ERROR

2021-09-12 Thread meng_xiaohui

New submission from meng_xiaohui <1294886...@qq.com>:

There is a bug in this method:

L.sort(key=None, reverse=False) -> None
L is an instance of list.

Argument key is a function. If L is in the body of argument key, L is always an 
empty list in test case, which is wrong

=
Run this:

F = ['2', '3', '1']
G = ['7', '9', '8']

def key(i):
print(F)
print(G)
res = int(i) + len(F) + len(G)
return res

G.sort(key=key)
F.sort(key=key)

=
Actual output:
['2', '3', '1']
[]
['2', '3', '1']
[]
['2', '3', '1']
[]
[]
['7', '8', '9']
[]
['7', '8', '9']
[]
['7', '8', '9']

--
components: Interpreter Core
messages: 401679
nosy: meng_xiaohui
priority: normal
severity: normal
status: open
title: List.sort ERROR
type: behavior
versions: Python 3.8

___
Python tracker 

___
___
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com