Ad
  • Default User Avatar

    I don't know that it's best practice, per se, but I chuckled. Very clever.

  • Default User Avatar

    You might have a point with the 'x' variable, but that's the default argument of the kata as accepted, so I'm personally not inclined to fault the warrior. As for 'f' as a bad name, I disagree.

    It is a pythonic axiom that 'Readability Matters'. If 'f' were to be carried throughout a long function, I would say a more verbose name would be preferred, however in this instance it is a throwaway variable, used only within the context of the list comprehension. Further, PEP-8 standards require all code lines to be a maximum of 79 characters. As written, the line is 40 characters long (36 in the code + 4 in the indent). This particular comprehension could be accomplished with somewhat longer names, but what if it was one or two indentations deeper or had more involved logical statements? As a general rule, long names in a comprehension will balloon out of control very quickly. There's no need to stretch a line for throwaway variables.