Unidiomatic Introduction in "Guido's Gorgeous Lasagna" Exercise

Reading through the Introduction in the Guido’s Gorgeous Lasagna exercise, I noticed that it states, under the heading Calling Functions:

⁝
# Calling methods or functions in classes and modules.
>>> start_text = "my silly sentence for examples."
>>> str.upper(start_text)  # Calling the upper() method for the built-in str class.
"MY SILLY SENTENCE FOR EXAMPLES."
⁝

While this is a valid way to use the .upper() method for strings in Python, I’m pretty sure a more Pythonic way would be start_text.upper()
The expression is unusual, in a sense, and given that it’s one of the first problems to be practised, it might be worth considering to use the more idiomatic expression, of which I stated above.

Well, the issue isn’t that significant anyways, but it’s just odd to me.

I completely agree … but then it wouldn’t be an example of what it’s trying to show: calling a method using a class namespace.

3 Likes

Ah, I see, that makes sense.
I guess in my confusion about the expression I’ve overlooked the context of that example.
Well, thanks for clarifying!

1 Like