Skip to main content
Improved the naming suggestions
Source Link
Phrancis
  • 20.5k
  • 6
  • 69
  • 155

Please improve your naming!

I've come to love the "straight-to-the-point" Python syntax a lot, and I embrace the delicious syntactic sugar of the language; but I keep seeing really bad naming of things among Python programmers. Maybe try this?

def character_to_decimalnumber_as_string_to_decimal(stringnumber_as_string):
    decimal = 0
    base = ord('0')
    for character in stringnumber_as_string:
        decimal = decimal * 10 + ord(character) - base
    return decimal

Please improve your naming!

I've come to love the "straight-to-the-point" Python syntax a lot, and I embrace the delicious syntactic sugar of the language; but I keep seeing really bad naming of things among Python programmers. Maybe try this?

def character_to_decimal(string):
    decimal = 0
    base = ord('0')
    for character in string:
        decimal = decimal * 10 + ord(character) - base
    return decimal

Please improve your naming!

I've come to love the "straight-to-the-point" Python syntax a lot, and I embrace the delicious syntactic sugar of the language; but I keep seeing really bad naming of things among Python programmers. Maybe try this?

def number_as_string_to_decimal(number_as_string):
    decimal = 0
    base = ord('0')
    for character in number_as_string:
        decimal = decimal * 10 + ord(character) - base
    return decimal
Source Link
Phrancis
  • 20.5k
  • 6
  • 69
  • 155

Please improve your naming!

I've come to love the "straight-to-the-point" Python syntax a lot, and I embrace the delicious syntactic sugar of the language; but I keep seeing really bad naming of things among Python programmers. Maybe try this?

def character_to_decimal(string):
    decimal = 0
    base = ord('0')
    for character in string:
        decimal = decimal * 10 + ord(character) - base
    return decimal