pythonpython-3.xpylintpycodestyle

what is best practice to control "too many local variable in a function" without suppress and manipulate pylint settings?


I'm working to make sure python code files must be 10/10 score with regular pylint and pycodestyle. but, I'm getting hard change from "too many local variable" in the functions. The functions could to split due to timing issue of whole suite. please suggest some best practice or suggestions.

Thanks in advance!!


Solution

  • You are providing too little information. That said, here are some basic ideas:

    For example:

    from collections import namedtuple
    Record = namedtuple('Record', 'course name id midterm1 midterm2 homework')
    input_array_line = ['botony', 'chad', '123456', 88.0, 92.2, 40]
    r = Record(*input_array_line)
    score = (r.midterm1 + r.midterm2) * .45 + (r.homework/40.0) * 10.0
    

    Good luck! Keep coding! Keep notes.