

You define it in exactly the same way you just did. Completely fine, you have to do it for lots of things. It’s nice that Python can do that too.
Now, I’ll grab a random snippet of code from some random file from my source dir:
existing_bookmarks = db.session.execute(
text('SELECT post_reply_id FROM "post_reply_bookmark" WHERE user_id = :user_id'),
{"user_id": user_id}).scalars()
reply = PostReply.query.filter(PostReply.id.in_(existing_bookmarks), PostReply.deleted == False).first()
if reply:
data = {"comment_id": reply.id, "save": True}
with pytest.raises(Exception) as ex:
put_reply_save(auth, data)
assert str(ex.value) == 'This comment has already been bookmarked.'
You can see some classes in use, which again is fine. But you also see inline instantiation of some reply JSON, a database returning a list of post_reply_id values without needing a special interface definition for returning multiple values, lots and lots of cognitive and computational load per line of code that’s being saved because the language features are saving people the heavy lifting of depending on user-defined classes for everything. It means you don’t have as many adventures through the code where you’re trying to modify a user-defined interface class, you don’t need as much strong typing, that kind of thing.
I would bet heavily that a lot of the things that are happening in that short little space of code, would need specific classes to get them done if the same project were getting implemented in some C+±derived language. Maybe not, I just grabbed a random segment of code instead of trying especially hard to find my perfect example to prove my point.
It is fine, there are significant weaknesses to Python too, I’m not trying to say “yay python it’s better for everything,” anything like that. I’m just saying that if you don’t get familiar with at least some language that does things more that way, and instead get solely accustomed to just user-defined classes or templates for every information exchange or functional definition, then you’ll be missing out on a good paradigm for thinking about programming. That’s all.
Dude you were the one that asked the fucking question lol