This is an older video; I use a bigger font nowadays.
@Alan910127 Жыл бұрын
There's an ORM package called SQLModel created by the author of FastAPI, which is built on top of SQL Alchemy and Pydantic, utilized the __init_subclass__ dunder method to distinguish the defined class should be a database table or just or a normal Pydantic model.
@doritorick Жыл бұрын
Hey, great video showcasing those methods! I was wondering, how did you manage to get that beautiful, clean terminal? Mine shows unnecessary paths and details and a bunch of other ugly stuff before actually displaying the output of my program. Perhaps you could make a tutorial on how to clean up the terminal?
@Carberra Жыл бұрын
I have one already! kzbin.info/www/bejne/aoPYeH5prJuAmNU The config I actually use day-to-day is this: github.com/parafoxia/dotfiles/blob/main/.config/starship.toml
@airatvaliullin84209 ай бұрын
13:19 I think it'd be better to raise a TypeError when trying to compare the object with an object of a different type: from typing import Self def __eq__(self, other: Self) -> bool: if not isinstance(other, self.__class__): raise TypeError(f'The equality operator is not defined between {self.__class__} and {other.__class__} ') return ... # normal logic between two instances of Self This wouldn't let such comparisons (which are almost surely errors) run quietly.
@Carberra9 ай бұрын
I can certainly see this being preferable in certain situations, but the default behaviour when comparing equity between two non-equal types is to just return False. `return NotImplemented` does indeed do that (I've double checked since making this video), and if you compare, say, and string and an int, you'll get that behaviour.
@airatvaliullin84209 ай бұрын
@@Carberra hmm, true, I didn't know that... I thought it'd make more sense to throw an exception (like they do with the other comparison operators)
@Carberra9 ай бұрын
It does definitely make sense from a consistency standpoint to throw an error. But then I spose logically, if two things are different objects, they're not equal so you can easily get an answer. That's my theory why they went for that anyways.