To suppress the warning, one can simply name the variable with an underscore ('_') alone. Python treats it as an unused variable and ignores it without giving the warning message.
In general, don't worry about deleting variables. Python has garbage collection, so any objects that you can no longer access (usually because you've left their scope) will automatically be freed from memory, you don't have to worry about this at all.
As mentioned, PEP 8 says to use lower_case_with_underscores for variables, methods and functions.
When having a function in Python that returns a couple of variables, for example:
row, column = search_in_table(table_name, search_for)
Sometimes you only need to use one of the variables returned by the function. But when this happens, the line is marked with a PEP8 Unused Variable
warning.
How can I handle this situation so I can comply with all the PEP8 rules?
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With