Interface and duck typing woes

Joshua Landau joshua at landau.ws
Sat Aug 31 19:18:54 EDT 2013


On 31 August 2013 01:13, Steven D'Aprano
<steve+comp.lang.python at pearwood.info> wrote:
> On Fri, 30 Aug 2013 06:35:47 -0400, Roy Smith wrote:
>
>> In article <52200699$0$6599$c3e8da3$5496439d at news.astraweb.com>,
>>  Steven D'Aprano <steve+comp.lang.python at pearwood.info> wrote:
>>
>>> These days, it would be relatively simple to implement pre- and post-
>>> condition checking using decorators, and indeed one of the motivating
>>> use- cases for function annotations in Python 3 is to allow such
>>> things.
>>>
>>> http://www.python.org/dev/peps/pep-3107/
>>>
>>> (Function annotations are perhaps the best Python feature that nobody
>>> uses.)
>>
>> This is awesome.
>
> Heh, everybody has one of two reactions:
>
> "This is awesome!"
>
> "You'll add type checking to my Python code over my dead body!!!"
>
> But I'm still to see a practical use for annotations in real world code.
> Or indeed to think of a use for them other than type checking.

I occasionally use them for documentation. I think that there some are
cases where the return type (encoded as a string) is as good an indicator
of functionality as a short docstring, so use both.



More information about the Python-list mailing list