3 ms·
sum_and_stringify(nums: List[int]) -> str: This looks so bad. I think Python is making a big mistake with this. The commented version is much more acceptable.
by RodericDay 10y ago
sum_and_stringify(nums: List[int]) -> str:
This looks so bad. I think Python is making a big mistake with this.
The commented version is much more acceptable.
- zanny 10y agoIts basically the same syntax as Rust, which I honestly like. I mean, I didn't like the syntax to begin with (I have always been a stickler for how name: type introduces a superfluous colon over type name syntax) and using two glyphs for returns is horrible, but since several languages are now doing this, if you are going to do it, you might as well keep it consistent.
- RodericDay 10y agoddfisher up there is already talking about stuff like ---- It should work with the Python 3 syntax if you quote your type annotation. I.e. def f() -> "Bar": ... instead of def f() -> Bar: ... --- Yeah, you need to write `from typing import List` to get the generic List class that you can parameterize with an item type. As you pointed out, you can use the builtin lowercase-l list without importing anything, but that doesn't allow you to specify the item type. --- imo, this is brutal. I'll just wait and see whether I'm proven right or wrong, but the extremely poor aesthetics of the whole thing bode badly.