3 ms·
The problem with this is something most Pythonistas don’t think about, the return type of the function. Officially it’s either a None or Int. But most people w
by whb07 6y ago
The problem with this is something most Pythonistas don’t think about, the return type of the function.
Officially it’s either a None or Int. But most people would just say Int. Will cause problems obv when not properly handled.
- hannofcart 6y agoPython type annotations, especially the 'Optional' type annotation in conjunction with a good typechecker like mypy alleviates this problem.
- whb07 6y agoAgreed, there is a perverse attitude where people jump into Python for the “it just works!” mentality, and hate the idea of type annotations.
- zo1 6y agoI'm confused, the function doesn't return anything so why would it be an int return type? It should be "None" because it's a void function.
- whb07 6y agoOof well let’s just assume it did, it’s a view about the specific user-ID so in theory it would return that. I misread and then I’ll blame my mind for thinking implicit return as last line ;)