Python Forum
Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Finding dead code
#3
Try https://pypi.python.org/pypi/vulture

There are some Python IDE's which will mark unused variables or code which is not used. Sublime Text will do it, I think. May be Atom too.

Edit:
I've wrote this simple code:

#!/usr/bin/env python3
import sys

a = 2
b = 3
c = 4


def print_hw():
    print("hello, world")


def add_nums(x, y):
    return x + y


def main():
    print(add_nums(a, b))
    print(dir(__name__))

if __name__ == '__main__':
    sys.exit(main())
So, Sublime, Atom and Ninja IDE, no one of these has showed the unused code...

I've tried pychecker, pyflakes and vulture. Only the last one has printed out some result.

victor@jerry:~$ vulture -v dead_code_test.py | grep 'Unused'
dead_code_test.py:6: Unused variable 'c'
dead_code_test.py:9: Unused function 'print_hw'
"As they say in Mexico 'dosvidaniya'. That makes two vidaniyas."
https://freedns.afraid.org
Reply


Messages In This Thread
Finding dead code - by Ofnuts - Dec-20-2016, 11:31 AM
RE: Finding dead code - by Larz60+ - Dec-20-2016, 11:54 AM
RE: Finding dead code - by wavic - Dec-20-2016, 01:46 PM
RE: Finding dead code - by micseydel - Dec-20-2016, 05:21 PM
RE: Finding dead code - by Ofnuts - Dec-20-2016, 08:51 PM
RE: Finding dead code - by Larz60+ - Dec-20-2016, 08:55 PM
RE: Finding dead code - by wavic - Dec-20-2016, 09:00 PM

Possibly Related Threads…
Thread Author Replies Views Last Post
  (OpenCV) Help to improve code for object detection and finding center of it saoko 0 1,233 May-14-2022, 05:34 PM
Last Post: saoko
  code for finding a cables crossed the bondary of the city spider_pytthon 8 3,610 Dec-24-2019, 07:23 AM
Last Post: spider_pytthon
  I need help finding an error in this code I have Tacnoblode 1 2,736 Jul-18-2018, 05:51 AM
Last Post: buran
  code wanted: finding absent characters Skaperen 2 3,006 Mar-26-2018, 03:12 AM
Last Post: Skaperen
  Trouble finding Python code Larz60+ 5 4,413 Jun-02-2017, 01:30 PM
Last Post: sparkz_alot

Forum Jump:

User Panel Messages

Announcements
Announcement #1 8/1/2020
Announcement #2 8/2/2020
Announcement #3 8/6/2020