Apr-07-2018, 03:59 PM
It is very frustrating when a program runs to completion with no errors and gives unexpected output, when you thought you did everything correctly. In my case it was faulty syntax. I used
Luckily
Sample code that demonstrates the problem:
https://pylint.readthedocs.io/en/latest/intro.html
https://pylint.readthedocs.io/en/latest/
https://pypi.python.org/pypi/pylint
Lewis
my_list.sort
instead of my_list.sort()
.Luckily
Pylint
gave me a warning message that gave me a clue on how to fix the problem.Sample code that demonstrates the problem:
my_list = ['bbb', 'ddd', 'aaa', 'ccc'] #NOTE: 'sep' argument defines the separator between print items print() print("Printing the original list\n", my_list, sep="") #The 'mylist.sort' line generates the following Pylint WARNING: [W0104(pointless-statement), ] Statement seems to have no effect print() my_list.sort print("Printing the list after 'mylist.sort' (bad function call - does not sort)\n", my_list, sep="") print() my_list.sort() print("Printing the list after 'mylist.sort()'\n", my_list, sep="")
Output:Printing the original list
['bbb', 'ddd', 'aaa', 'ccc']
Printing the list after 'mylist.sort' (bad function call - does not sort)
['bbb', 'ddd', 'aaa', 'ccc']
Printing the list after 'mylist.sort()'
['aaa', 'bbb', 'ccc', 'ddd']
For more information about Pylint see:https://pylint.readthedocs.io/en/latest/intro.html
https://pylint.readthedocs.io/en/latest/
https://pypi.python.org/pypi/pylint
Lewis
To paraphrase: 'Throw out your dead' code. https://www.youtube.com/watch?v=grbSQ6O6kbs Forward to 1:00