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

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

anthonywritescode

anthonywritescode

Күн бұрын

Пікірлер: 21
@WaylonWalker
@WaylonWalker 3 жыл бұрын
I like when you keep the stream cam setup
@shubhamjoshi6826
@shubhamjoshi6826 4 жыл бұрын
thank you Anthony 😊
@ng3147
@ng3147 Жыл бұрын
exactly the explanation i needed. thank you!
@mmoussa01
@mmoussa01 4 жыл бұрын
"from typing import Optional as Noneable" 😁
@anthonywritescode
@anthonywritescode 4 жыл бұрын
too true!
@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)"
@MatthewPherigo
@MatthewPherigo Жыл бұрын
In NixOS types, this is called "NullOr", maybe more clear.
@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
@srkbhayo
@srkbhayo 2 жыл бұрын
thank you . I was sos confused with this keyword
@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.
@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
@realabja1
@realabja1 3 жыл бұрын
You awesome man🚀
@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...
@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
oops I'm the pyuwsgi maintainer now (intermediate) anthony explains #579
22:55
VIP ACCESS
00:47
Natan por Aí
Рет қаралды 30 МЛН
Chain Game Strong ⛓️
00:21
Anwar Jibawi
Рет қаралды 41 МЛН
Python Typing - Type Hints & Annotations
24:46
Tech With Tim
Рет қаралды 117 М.
python Generics (intermediate) anthony explains #430
13:43
anthonywritescode
Рет қаралды 16 М.
Intro to async Python | Writing a Web Crawler
14:23
mCoding
Рет қаралды 82 М.
python typing: TYPE_CHECKING (intermediate) anthony explains #312
13:31
anthonywritescode
Рет қаралды 4,3 М.
Python Data Classes Are AMAZING! Here's Why
16:11
Tech With Tim
Рет қаралды 87 М.
Python: A Quick Guide To Type Annotations (ft. Mypy)
11:25
Indently
Рет қаралды 35 М.
Python 3.12 Generic Types Explained
18:27
ArjanCodes
Рет қаралды 65 М.
“typing” is getting deprecated in Python
7:20
Indently
Рет қаралды 79 М.
КОРОЧЕ ГОВОРЯ, НЕДЕЛЯ БЕЗ ТЕЛЕФОНА
3:54
Карина Кросс #shorts
0:16
Dolly and Friends Shorts Cartoons
Рет қаралды 361 М.
When the PHONE CASE can be your BEST FRIEND! #shorts
0:33
One More
Рет қаралды 18 МЛН
Карина Кросс #shorts
0:16
Dolly and Friends Shorts Cartoons
Рет қаралды 361 М.
Making of Marble in Factory #shorts #ashortaday #indianstreetfood
0:59
Indian Food Vlogs
Рет қаралды 6 МЛН
ПОСТАРЕЛА ЗА 1 ДЕНЬ НА 20 ЛЕТ - МУЖСКОЕ ЖЕНСКОЕ
55:44
ПРИЯТНЫЙ ИЛЬДАР
Рет қаралды 677 М.