12
Protocols in Python (til.simonwillison.net)
you are viewing a single comment's thread
view the rest of the comments
[-] zeusbottom@sh.itjust.works 3 points 1 year ago

It’s very weird to me that Python, as an inherently untyped language, is trying to bolt on stronger typing through modules like Protocol and typing.

If typing is a good thing, why not make it an optional first-class part of the language? Maybe make strong typing a one liner option at the top of a source file? This growing maze of modules and recommendations is so unwieldy. For example, the typing module works kind of in conjunction with language elements that aren’t what newbs learn in Python 101, like type specifiers in function args. I feel like this stuff is driving Python away from simplicity.

[-] lysdexic@programming.dev 2 points 1 year ago

It’s very weird to me that Python, as an inherently untyped language

I don't think this is true. Python is dynamically typed, but types exist. More importantly, Python is the poster child of duck typing. What is duck typing if not a way to implicitly specify protocols? If you're relying on protocols to work, why not have tests for it? If you want to test protocols, aren't you actually doing type checks?

If typing is a good thing,

...which undoubtedly is.

(...) why not make it an optional first-class part of the language?

It already is, isn't it?

But some people already have Python code that does not do type checking. What would be the point of refusing to run that code?

load more comments (5 replies)
this post was submitted on 26 Jul 2023
12 points (100.0% liked)

Python

6300 readers
8 users here now

Welcome to the Python community on the programming.dev Lemmy instance!

📅 Events

PastNovember 2023

October 2023

July 2023

August 2023

September 2023

🐍 Python project:
💓 Python Community:
✨ Python Ecosystem:
🌌 Fediverse
Communities
Projects
Feeds

founded 1 year ago
MODERATORS