python typing: Optional is not optional! (intermediate) anthony explains

  Рет қаралды 6,531

anthonywritescode

anthonywritescode

Күн бұрын

Пікірлер: 21
@mmoussa01
@mmoussa01 4 жыл бұрын
"from typing import Optional as Noneable" 😁
@anthonywritescode
@anthonywritescode 4 жыл бұрын
too true!
@ng3147
@ng3147 Жыл бұрын
exactly the explanation i needed. thank you!
@WaylonWalker
@WaylonWalker 3 жыл бұрын
I like when you keep the stream cam setup
@MatthewPherigo
@MatthewPherigo Жыл бұрын
In NixOS types, this is called "NullOr", maybe more clear.
@shubhamjoshi6826
@shubhamjoshi6826 4 жыл бұрын
thank you Anthony 😊
@brianfontenot9925
@brianfontenot9925 3 жыл бұрын
Optional is really a type that means we have a box and inside the box maybe there is some(value) or none(value). Its a great tool if enforced and completely eliminates the runtime nil/null reference at “compile” time. If incorporated into the language correctly
@goodclover
@goodclover 4 жыл бұрын
30:32 I'm sure there's plenty of other thing that you would want to change as well. 😅
@retrom
@retrom 4 жыл бұрын
damn, which dimension is 30minutes into a 4minute video
@goodclover
@goodclover 4 жыл бұрын
@@retrom I have no idea what happened there.
@Strider817
@Strider817 4 жыл бұрын
I'm one of those people confused by this naming, and your video helped quite a bit in explaining stuff. However, I still don't understand why you can't set an optional function argument to Optional[int], since it seems like Optional means the type could be either Int or None. In your function y is an int when set by default, so why is it not valid to do this?
@anthonywritescode
@anthonywritescode 4 жыл бұрын
you can use Optional[int] to annotate a function argument, however it has a different meaning than "this argument is optional" -- it actually means something closer to "this argument is None-able (nullable, but translated to pythonspeak)"
@srkbhayo
@srkbhayo 2 жыл бұрын
thank you . I was sos confused with this keyword
@sadhlife
@sadhlife 4 жыл бұрын
that new | syntax has already landed in 3.10 apparently
@anthonywritescode
@anthonywritescode 4 жыл бұрын
indeed! I've got it in my copy of 3.10a2! >>> int | None int | None
@sadhlife
@sadhlife 4 жыл бұрын
@@anthonywritescode noice
@shivanshmishra5293
@shivanshmishra5293 4 жыл бұрын
Trying to replicate maybe monad I guess.
@anthonywritescode
@anthonywritescode 4 жыл бұрын
I mean, it's clear what it is -- just the name is bad :)
@nexovec
@nexovec Жыл бұрын
Even Option[int] would be way better I don't get it...
@realabja1
@realabja1 3 жыл бұрын
You awesome man🚀
@MElixirDNB
@MElixirDNB Жыл бұрын
OrNone might have been more intuitive. but now we can just use the easier | None syntax.. although lots of work environments are stuck on older python versions so pain ensues
python Generics (intermediate) anthony explains #430
13:43
anthonywritescode
Рет қаралды 16 М.
We Attempted The Impossible 😱
00:54
Topper Guild
Рет қаралды 56 МЛН
Каха и дочка
00:28
К-Media
Рет қаралды 3,4 МЛН
It works #beatbox #tiktok
00:34
BeatboxJCOP
Рет қаралды 41 МЛН
Python: A Quick Guide To Type Annotations (ft. Mypy)
11:25
Indently
Рет қаралды 35 М.
virtualenv vs. venv (beginner - intermediate) anthony explains #040
11:22
anthonywritescode
Рет қаралды 44 М.
The Best Way to Check for Optional Arguments in Python
4:04
5 Python Libraries You Should Know in 2025!
22:30
Keith Galli
Рет қаралды 66 М.
How Senior Programmers ACTUALLY Write Code
13:37
Thriving Technologist
Рет қаралды 1,6 МЛН
It’s time to move on from Agile Software Development (It's not working)
11:07
debugging a broken cache!
21:16
anthonywritescode
Рет қаралды 4,1 М.
python: explicit relative imports (intermediate) anthony explains #298
8:19
We Attempted The Impossible 😱
00:54
Topper Guild
Рет қаралды 56 МЛН