|
|
|
|
|
by djur
3751 days ago
|
|
Not having touched Python for many years, four things jump out at me: 1) .format, which isn't immediately familiar and doesn't resemble similar string formatters in other languages
2) [1:], which I believe is a string slicing syntax that doesn't resemble similar syntax in other languages
3) Bug: nothing is done with the capitalized words, since the return value is thrown away
4) Bug: the name of the function was misspelled when used. The last one may seem like a nitpick, but it is true that when you add a name to your code for the sake of clarity, you also take on the additional burden of ensuring the name is used consistently and accurately everywhere. This can be a particular pain in cases where you are generating a lot of uninteresting temporary values -- which is precisely why people end up writing chained function or method calls. |
|
Point 2, this type of string slicing syntax is pretty common in languages similar to Python. A very similar syntax exists in Ruby and Perl. See https://en.wikipedia.org/wiki/Array_slicing for more examples of slice shorthand in the wild.
Point 3. I didn't intend to rewrite the whole thing again, just enough to demonstrate my problems with the reply's lambda-based approach. This is indicated by the ellipsis. If I were to create a full version instead of the quick demonstration of the more-clear full function definition here, then yes, I would've assigned the output of the function to something.
4. Conceded.