delete
statement in a local scope PTC-W0043del
statement in a local scope118 tit_links.append(p)
119 except Exception:
120 pass
121 del list_a_s122 if not tit_links:
123 return False
124 return choice(tit_links)
Passing a local variable to a del
statement results in that variable being removed from the local namespace.
When exiting a function all local variables are deleted, so it is unnecessary to explicitly delete variables in such cases.
It is recommended to remove this del
statement.
Not preferred:
def my_func():
task = do_some_task()
evaluate_task(task)
del task # This is unnecessary.
Preferred:
def my_func():
task = do_some_task()
evaluate_task(task)