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: Bug in reverse method
Type: behavior Stage: resolved
Components: Versions: Python 3.6
process
Status: closed Resolution: not a bug
Dependencies: Superseder:
Assigned To: Nosy List: rajesh99div99, steven.daprano
Priority: normal Keywords:

Created on 2018-09-12 12:55 by rajesh99div99, last changed 2022-04-11 14:59 by admin. This issue is now closed.

Messages (2)
msg325136 - (view) Author: Rajesh (rajesh99div99) Date: 2018-09-12 12:55
List.reverse()    .... this is working in reverse order 
List.reverse      ....this is not giving syntax error and printing the list as it is.

Can you consider this as bug and fix it in further versions ?
msg325137 - (view) Author: Steven D'Aprano (steven.daprano) * (Python committer) Date: 2018-09-12 13:25
This is not a bug or a syntax error, and the behaviour goes back to at least Python 1.5 if not older.

List.reverse returns a reference to the method object itself. List.reverse() *calls* the method. This is standard behaviour in Python, all methods and functions are first-class values, anything you can do with an object, you can do with a function or method too. For example:

py> list.reverse.__name__
'reverse'
py> print(len)
<built-in function len>
py> alist = [1, "a", chr]
py> print(alist)
[1, 'a', <built-in function chr>]
History
Date User Action Args
2022-04-11 14:59:05adminsetgithub: 78825
2018-09-12 13:25:13steven.dapranosetstatus: open -> closed

nosy: + steven.daprano
messages: + msg325137

resolution: not a bug
stage: resolved
2018-09-12 12:55:11rajesh99div99create