Re: Python (was Re: Recent history of vi)

Lawrence D’Oliveiro <[email protected]> Sat, 20 Dec 2025 22:28:19 -0000 (UTC)
Newsgroups comp.os.linux.misc,alt.folklore.computers,comp.lang.python
Organization A noiseless patient Spider
Message-ID <[email protected]>
On Sat, 20 Dec 2025 10:12:49 +0000, Richard Kettlewell wrote:

> Another property suggested in [1] for ‘strong typing’ is that
> functions can only be called with with arguments matching a declared
> type. In Python, function arguments do not have declared types[2]
> and does not even infer them; anything goes. You will only hit an
> exception if you try to use the arguments in the wrong way.

Python calls this “duck typing”. The called code expects the passed
objects to have certain members; so long as they have those, they can
be of any type. E.g. a function might be written to write to an output
file object, but anything passed that has a suitable “.write()” method
on it will work.

In other words, if it looks like a duck and quacks like a duck, then
it is acceptable in place of a duck.