Error:
old-ne-operator, Use of the <> operator
Description
Raised by pylint, when old inequality operator <> is used. This error is not
fatal but considered a bad
practice and could result in unexpected behavior.
Example(s)
Given sample of code describe
basic divide function, it takes
two arguments a and b. We have simple divided first argument with second
and
returned result. We have calculated division in case of inequality while constant 1 for equality case.
"""
function to take two arguments to divide first by second
"""
try:
if a <> b:
result = a/b
else:
result = 1
except ZeroDivisionError:
result = 0
return result
Solution(s)
This could be resolved using standard != for testing not equal.
Use !=
"""
function to take two arguments to divide first by second
"""
try:
if a != b:
result = a/b
else:
result = 1
except ZeroDivisionError:
result = 0
return result
No comments:
Post a Comment