Tuesday 2 September 2014

Use of "l" as long integer identifier :: Pylint :: W0332


Error:

lowercase-l-suffix, Use of "l" as long integer identifier

Description

Raised by pylint, Use of “l” as long integer identifier Used when a lower case “l” is used to mark a long integer. You should use a upper case “L” since the letter “l” looks too much like the digit “1”

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 as long integer for equality case.

def divide(a, b):
    """
    function to take two arguments to divide first by second
    """
    try:
        if a != b:
            result = a/b
        else:
            result = 1l
    except ZeroDivisionError:
        result = 0
    return result



Solution(s)

This could be resolved using Capital "L" to represent long Integer.

Use "L"


def divide(a, b):
    """
    function to take two arguments to divide first by second
    """
    try:
        if a != b:
            result = a/b
        else:
            result = 1L
    except ZeroDivisionError:
        result = 0
    return result

No comments:

Post a Comment