|
|
Log in / Subscribe / Register

Growing pains for typing in Python

Growing pains for typing in Python

Posted Jan 18, 2024 2:55 UTC (Thu) by warrax (subscriber, #103205)
In reply to: Growing pains for typing in Python by Paf
Parent article: Growing pains for typing in Python

> Duck typing is a really fun way to program small stuff quickly.

I'm going to be nit-picky here. O'Caml is statically typed and supports Duck typing ("Structural types"). The term you're looking for is Run-time Type Checking.


to post comments

Growing pains for typing in Python

Posted Jan 18, 2024 6:22 UTC (Thu) by benhoyt (subscriber, #138463) [Link]

Perhaps the term the original commentor was looking for was "run-time type checking", but to nitpick your nitpick :-), Python (without type annotations) definitely uses duck typing extensively, which is a form of run-time type checking. I'm not sure the term "duck typing" was coined for Python, but pretty close -- Pythonista Alex Martelli used the term on comp.lang.python back in 2000 [1]. See also the term in the Python glossary. [2]

In statically typed languages like O'Caml and Go, the related concept is called "structural typing" and not "duck typing". In Python with type annotations, structural typing (statically checked) is supported with PEP 544 "protocols". [3]

See also the sections on typing in the Wikipedia articles about Python [4] and O'Caml [5].

[1] https://groups.google.com/g/comp.lang.python/c/CCs2oJdyuz...
[2] https://docs.python.org/3/glossary.html#term-duck-typing
[3] https://docs.python.org/3.8/library/typing.html#nominal-v...
[4] https://en.wikipedia.org/wiki/Python_(programming_language)#Typing
[5] https://en.wikipedia.org/wiki/OCaml#Features


Copyright © 2026, Eklektix, Inc.
Comments and public postings are copyrighted by their creators.
Linux is a registered trademark of Linus Torvalds