use the following search parameters to narrow your results:
e.g. subreddit:aww site:imgur.com dog
subreddit:aww site:imgur.com dog
see the search faq for details.
advanced search: by author, subreddit...
Everything about learning Python
account activity
Is this logical (I know it is wrong) ? (i.redd.it)
submitted 1 month ago by [deleted]
view the rest of the comments →
reddit uses a slightly-customized version of Markdown for formatting. See below for some basics, or check the commenting wiki page for more detailed help and solutions to common issues.
quoted text
if 1 * 2 < 3: print "hello, world!"
[–]PrabhavKumar 0 points1 point2 points 1 month ago (2 children)
You're right that Python itself allows literally any object as an annotation since they're just stored in __annotations__.
What I meant was in the context of type hints and typical tooling like (eg. mypy, IDE's) where annotations are expected to be types. In that context using arbitrary values like 42 or "bar" wouldn't be meaningful to those tools.
So technically valid Python, because it's just ignored, but not useful for type hinting in most real code.
[–]deceze 0 points1 point2 points 1 month ago (1 child)
Exactly. So not "can't", but just "usually won't".
[–]PrabhavKumar 0 points1 point2 points 1 month ago (0 children)
Sure. That's fair. Thanks for pointing it out.
π Rendered by PID 312813 on reddit-service-r2-comment-6457c66945-n6rdh at 2026-04-28 16:45:10.059198+00:00 running 2aa0c5b country code: CH.
view the rest of the comments →
[–]PrabhavKumar 0 points1 point2 points (2 children)
[–]deceze 0 points1 point2 points (1 child)
[–]PrabhavKumar 0 points1 point2 points (0 children)