4 ms·
I got frustrated on the very first example (Basic 1: Any) because I didn't realize that the typings library wasn't imported by default. Maybe I should have know
by vsnf 3y ago
I got frustrated on the very first example (Basic 1: Any) because I didn't realize that the typings library wasn't imported by default. Maybe I should have known better, but it definitely got me.
- burning_hamster 3y agoI made the same error. OP, maybe instead of only giving the option to see the solution, also give the option to just see a hint?
- burning_hamster 3y agoAlso, a "Next example" button would be great.
- laike9m 3y agoI definitely considered adding hints. But it's gonna be a ton of work to create proper hints and I'm yet to prioritize it.
- v3ss0n 3y agoyou aren't wrong , any is available in python 3.10 . There is no need to import typing.Any
- karamanolev 3y agoThose are completely different. any - https://docs.python.org/3/library/functions.html#any https://docs.python.org/3/library/functions.html#any - Return True if any element of the iterable is true. Any - A special kind of type is Any. A static type checker will treat every type as being compatible with Any and Any as being compatible with every type.
- nicolaslem 3y agoLet's not forget ANY as in "from unittest.mock import ANY".
- v3ss0n 3y agoWhoops, I always thought I can use any as type. Damn my bad
- _ZeD_ 3y agowhat? `any` - the builtin function[0] is part of python since the dawn of time but from what I know is not usable as a type annotation, and `typing.Any` should be used (and imported explicitly) [0] https://docs.python.org/3/library/functions.html#any https://docs.python.org/3/library/functions.html#any
- BiteCode_dev 3y agoI still think callable, and iter should be usable this way. any(), probably not. The semantic is too different. But having to import Callable while callable is a built-in is a missed opportunity. I don't miss Union, Optional and List.
- roland35 3y agoWell, that is realistic :D I agree it is a pain point with python typing, but it is something good to learn in this activity and remember honestly!
- hsfzxjy 3y agoI passed the test with `object` :)
- quietbritishjim 3y agoI literally didn't change the code, so there was no annotation at all, and it still passed.
- crunchbang-excl 3y agoI thought that one was an example where you don't have to do anything. I just went back to check and I saw that you are supposed to make some changes, which are shown in the solution, even though they are unnecessary to pass the tests.
- laike9m 3y agoThe "any" challenge is special, it's the only one where you don't need to make any changes :)
- georgehotelling 3y agoI opened an issue asking them to add `from typing import *` to the boilerplate.
- calibas 3y agoI assume that's intentional so you learn when it's required. From Python.org: "all functions without a return type or parameter types will implicitly default to using Any"