How is THIS a thing in Python?!
9:54
What's coming in Python 3.14?
6:24
Generics are VITAL in typed Python
16:54
Python 3.13's new REPL is AMAZING
10:21
Pydantic is OP, here's why
18:10
5 ай бұрын
Will Python SKIP these versions?
9:58
5 tips for CLEAN Python code
19:13
Пікірлер
@matis9783
@matis9783 12 сағат бұрын
Its awful
@dk4kja8
@dk4kja8 18 сағат бұрын
If they don't call it Pithon, I'm not downloading it
@tigrankhachatryan6119
@tigrankhachatryan6119 19 сағат бұрын
This is basically dependent typing but as non-native functionality. I hope they make better syntax for this in Python 4 if they ever create it
@DuncanBooth
@DuncanBooth 18 сағат бұрын
I think the syntax is fine because you don't have to use Annotated directly in the type annotation. for example pydantic.types.PositiveInt which is defined using Annotated but all you see in your Pydantic models is `field: PositiveInt`.
@ozymantiasVI
@ozymantiasVI 21 сағат бұрын
Wait, I thought assert would only trigger in debug
@Heavy_Lvy
@Heavy_Lvy 23 сағат бұрын
yay
@williamyoutube368
@williamyoutube368 2 күн бұрын
Hi Sir, I added the line "isort.args": ["--profile", "black"], but it is disabled due to: This setting cannot be applied because it is not registered as language override setting. Could you suggest how to fix? Thanks
@MrSonny6155
@MrSonny6155 2 күн бұрын
The best I could come up with is something like "0xfadin()" or "0xdecaffein[8]" as False and True respectively. Had some trouble getting "-and" to work and no convincing words exist for what few binary operator keywords exist in Python. Perhaps if you could somehow sneak in a context manager override on numbers elsewhere, maybe you could do something using "with 0x... as"?
@paulpasquel5905
@paulpasquel5905 3 күн бұрын
Magic :). Operators overloading on c++?
@NicolasVycasNery
@NicolasVycasNery 3 күн бұрын
/dev/random?
@tannerbobanner9453
@tannerbobanner9453 4 күн бұрын
As someone who has been using Annotated for quite a while now, I'm the right circumstances it can be unbelievably useful. I often find myself using it to create dynamic base classes like DAOs (Database Access Objects) or (de-)serialization objects.
@MrHopp24
@MrHopp24 4 күн бұрын
Singleton Pattern goes together well with the FastAPI dependency injection . Instead of depending on a concrete class, depend on a singleton that can only ever return a single instance of the concrete class
@jagansai007
@jagansai007 4 күн бұрын
Nice theme.. I what's that?
@Carberra
@Carberra 4 күн бұрын
Ayu Mirage -- I've got some videos about the setup in the description as well.
@kzczd
@kzczd 4 күн бұрын
I dont know if you're aware that youtube is auto-translating your videos titles, and it is making unninformative output, i would recommend to turn of title autotranslating because as a native spanish speaker, the youtube translator is underperformant.
@Carberra
@Carberra 4 күн бұрын
Is it? Thanks for the heads up, I'll see about turning that off. They're doing all sorts of stuff with translation and AI at the moment, doesn't surprise me it's not working very well considering it's Google.
@maksimon519
@maksimon519 4 күн бұрын
i dont see a point to do this instead of explicitly put it into parameter `metadata` of `field()`
@Carberra
@Carberra 4 күн бұрын
Is that what that argument's for? I guess now you say it it's pretty obvious, I hadn't put the two together haha. Either way, I just used a dataclass here to reduce boilerplate for the example.
@maleldil1
@maleldil1 4 күн бұрын
Dataclasses aren't the only place this shows up. You can do this in Pydantic classes (use Field(...) as metadata), FastAPI (as shown) and Typer (for CLI options).
@anferron
@anferron 4 күн бұрын
Looks more a MacOS than Windows. Maybe a virtual MacOS machine in your PC ?
@Carberra
@Carberra 4 күн бұрын
It's KDE Plasma themed to look (somewhat) like MacOS. I honestly love the dock + menubar way of doing things.
@imadetheuniverse4fun
@imadetheuniverse4fun 4 күн бұрын
so in the first example, it's just a way to "document" the validation next to the type, right? because the exact same thing could be achieved by just having the validation function be a standalone function and calling it in setattrs, or just having the logic hardcoded into setattrs directly.
@Carberra
@Carberra 4 күн бұрын
The second argument actually does get run, but it would also serve as a form of documentation, yeah. It's one of many ways it can be done, but is the way that is becoming more and more common that are built for the purpose of validation like Pydantic and Msgspec.
@endersteph
@endersteph 4 күн бұрын
Btw, there is a library called beartype which is amazing and lets you conveniently and efficiently define validators, and in general lets you easily enforce strict typing at practically 0 execution time-cost :)
@Carberra
@Carberra 4 күн бұрын
Oh wow, that's definitely worth a look-in! I remember seeing a library that enforced strict typing before and was trying to look for it earlier but couldn't find it. I'll give that one a shot!
@Proprogrammer001
@Proprogrammer001 4 күн бұрын
Why is pydantic not enough? is it performance?
@maleldil1
@maleldil1 4 күн бұрын
@@Proprogrammer001 Pydantic is mostly about data validation. Beartype can be used to check function parameters and stuff like that. Pydantic also has a similar thing (validate_call), but beartype's has a better API and is much faster.
@endersteph
@endersteph 4 күн бұрын
Shouldn't you add <is not None> in the if statements, in case the field/metadata is falsy?
@Carberra
@Carberra 4 күн бұрын
Mm, yeah probably actually. Most use-cases probably wouldn't be affected by it, but thanks for pointing it out nonetheless!
@eboyd53
@eboyd53 4 күн бұрын
This example excludes anyone who has yet to have a 1st birthday so be careful if your use case needs to include infants less than 1 year old.
@Carberra
@Carberra 4 күн бұрын
Oh yikes, so it does. Thanks for pointing that out!
@sarimbinwaseem
@sarimbinwaseem 4 күн бұрын
Definitely gonna try this, makes my work easier...
@luiss.l7904
@luiss.l7904 4 күн бұрын
Its rare to find "to the point" typing shown in python, its a pleasure to see such content.
@dipeshsamrawat7957
@dipeshsamrawat7957 5 күн бұрын
Thank you 😊
@uplink-on-yt
@uplink-on-yt 6 күн бұрын
Fix for shenanigans finds shenanigans in standard library. I'd be angry too.
@terra_creeper
@terra_creeper 6 күн бұрын
I'm not sure why you included the third example here, since I really don't see what is wrong with it. Yes, it's not clean, but it's not any less clean than (1+3)*(2+4) and I haven't seen anybody have issues with that.
@lokeshjain2008
@lokeshjain2008 6 күн бұрын
can someone please explain this code. I am not able to get why he used this and why this is bad. @carberra
@JonathanDenning
@JonathanDenning 6 күн бұрын
i teach programming languages at university, and i started collecting these a few years ago. i call them coding shenanigans. this is getting added!
@Carberra
@Carberra 6 күн бұрын
Care to share a few of your favourites? I'd be interested to know!
@JonathanDenning
@JonathanDenning 6 күн бұрын
@Carberra here's one... >>> (False == False) in [False] False >>> False == (False in [False]) False >>> False == False in [False] # what does this print? ???
@farzadmf
@farzadmf 7 күн бұрын
Where's NumPy here? 🤔
@qwkq
@qwkq 7 күн бұрын
[i for n, i in enumerate(DAYS) if MASK[n % len(MASK)]] does the same thing no? but the itertools/numpy approach is way more readable 😅
@Carberra
@Carberra 7 күн бұрын
The docs for compress give a rough equivalent as a one-liner with a zip, think it works somewhat similarly.
@transflux-us
@transflux-us 7 күн бұрын
What a weird name!
@Carberra
@Carberra 7 күн бұрын
Yeah it is a bit isn't it, not the most obvious thing in the world.
@isodoublet
@isodoublet 7 күн бұрын
So basically python developers are so traumatized by the 2 -> 3 transition that they're afraid to fix obvious parser bugs
@Carberra
@Carberra 7 күн бұрын
Not quite, Python 3.10 introduced features with syntax not possible using LL(1). I think the match statement? Something about the use of soft keywords iirc.
@isodoublet
@isodoublet 7 күн бұрын
@@Carberra Do any of those changes break previously working code (even if it obviously shouldn't code, as is the case with the examples given in this video)?
@burgerzach
@burgerzach 7 күн бұрын
It's a SELECTOR! 😂 But I guess MASK has fewer characters.
@Carberra
@Carberra 7 күн бұрын
I think both are fine -- mask is the term you'd use in Numpy, but yeah itertools uses "selectors".
@yaroslavpanych2067
@yaroslavpanych2067 8 күн бұрын
"Hexadecimal number gets transformed into integer number" Here we have example of people who don't know what they are talking about! It is either general trend, or this particular individual is dumb as hell! I'm even not going to continue watching!
@mage1over137
@mage1over137 8 күн бұрын
So these are basically puns in python
@Klownzer
@Klownzer 8 күн бұрын
Any reason why it won't allow me to use the bot unless if I have admin? Like I can't even use the ping command
@Carberra
@Carberra 7 күн бұрын
Unfortunately not, I don't think I've ever run into that. Try their support server: discord.gg/hikari
@alchenerd
@alchenerd 8 күн бұрын
I don't know what possessed me but here's a funny thing: ``` from warnings import filterwarnings as enemies # We do not overlook enemies enemies('ignore') # Instead, we silence them pledge = bool # Our pledge is resolute pledge(0x_for honor_x0) # The moment of truth: are we people of honor? ```