If they don't call it Pithon, I'm not downloading it
@tigrankhachatryan611919 сағат бұрын
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
@DuncanBooth18 сағат бұрын
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`.
@ozymantiasVI21 сағат бұрын
Wait, I thought assert would only trigger in debug
@Heavy_Lvy23 сағат бұрын
yay
@williamyoutube3682 күн бұрын
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
@MrSonny61552 күн бұрын
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"?
@paulpasquel59053 күн бұрын
Magic :). Operators overloading on c++?
@NicolasVycasNery3 күн бұрын
/dev/random?
@tannerbobanner94534 күн бұрын
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.
@MrHopp244 күн бұрын
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
@jagansai0074 күн бұрын
Nice theme.. I what's that?
@Carberra4 күн бұрын
Ayu Mirage -- I've got some videos about the setup in the description as well.
@kzczd4 күн бұрын
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.
@Carberra4 күн бұрын
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.
@maksimon5194 күн бұрын
i dont see a point to do this instead of explicitly put it into parameter `metadata` of `field()`
@Carberra4 күн бұрын
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.
@maleldil14 күн бұрын
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).
@anferron4 күн бұрын
Looks more a MacOS than Windows. Maybe a virtual MacOS machine in your PC ?
@Carberra4 күн бұрын
It's KDE Plasma themed to look (somewhat) like MacOS. I honestly love the dock + menubar way of doing things.
@imadetheuniverse4fun4 күн бұрын
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.
@Carberra4 күн бұрын
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.
@endersteph4 күн бұрын
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 :)
@Carberra4 күн бұрын
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!
@Proprogrammer0014 күн бұрын
Why is pydantic not enough? is it performance?
@maleldil14 күн бұрын
@@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.
@endersteph4 күн бұрын
Shouldn't you add <is not None> in the if statements, in case the field/metadata is falsy?
@Carberra4 күн бұрын
Mm, yeah probably actually. Most use-cases probably wouldn't be affected by it, but thanks for pointing it out nonetheless!
@eboyd534 күн бұрын
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.
@Carberra4 күн бұрын
Oh yikes, so it does. Thanks for pointing that out!
@sarimbinwaseem4 күн бұрын
Definitely gonna try this, makes my work easier...
@luiss.l79044 күн бұрын
Its rare to find "to the point" typing shown in python, its a pleasure to see such content.
@dipeshsamrawat79575 күн бұрын
Thank you 😊
@uplink-on-yt6 күн бұрын
Fix for shenanigans finds shenanigans in standard library. I'd be angry too.
@terra_creeper6 күн бұрын
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.
@lokeshjain20086 күн бұрын
can someone please explain this code. I am not able to get why he used this and why this is bad. @carberra
@JonathanDenning6 күн бұрын
i teach programming languages at university, and i started collecting these a few years ago. i call them coding shenanigans. this is getting added!
@Carberra6 күн бұрын
Care to share a few of your favourites? I'd be interested to know!
@JonathanDenning6 күн бұрын
@Carberra here's one... >>> (False == False) in [False] False >>> False == (False in [False]) False >>> False == False in [False] # what does this print? ???
@farzadmf7 күн бұрын
Where's NumPy here? 🤔
@qwkq7 күн бұрын
[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 😅
@Carberra7 күн бұрын
The docs for compress give a rough equivalent as a one-liner with a zip, think it works somewhat similarly.
@transflux-us7 күн бұрын
What a weird name!
@Carberra7 күн бұрын
Yeah it is a bit isn't it, not the most obvious thing in the world.
@isodoublet7 күн бұрын
So basically python developers are so traumatized by the 2 -> 3 transition that they're afraid to fix obvious parser bugs
@Carberra7 күн бұрын
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.
@isodoublet7 күн бұрын
@@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)?
@burgerzach7 күн бұрын
It's a SELECTOR! 😂 But I guess MASK has fewer characters.
@Carberra7 күн бұрын
I think both are fine -- mask is the term you'd use in Numpy, but yeah itertools uses "selectors".
@yaroslavpanych20678 күн бұрын
"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!
@mage1over1378 күн бұрын
So these are basically puns in python
@Klownzer8 күн бұрын
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
@Carberra7 күн бұрын
Unfortunately not, I don't think I've ever run into that. Try their support server: discord.gg/hikari
@alchenerd8 күн бұрын
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? ```