Python Sanity Proposal: Type Hinting Solution

Mark Lawrence breamoreboy at yahoo.co.uk
Sat Jan 24 18:36:06 CET 2015


On 24/01/2015 17:26, Steven D'Aprano wrote:
> Rick Johnson wrote:
>
>> On Saturday, January 24, 2015 at 7:30:02 AM UTC-6, Steven D'Aprano wrote:
>>> [...] It requires extra complexity to the parser, so that
>>> decorators may be separated from the function by a hint:
>>>
>>> @decorate
>>> "@typehint: (str, int) -> bool"
>>> def myfunction(arg1, arg2):
>>>
>>> No doubt some people will get them the wrong way around,
>>> and the type checker may silently ignore their hints:
>>>
>>> "@typehint: (str, int) -> bool"
>>> @decorate
>>> def myfunction(arg1, arg2):
>>>
>>> And others will write:
>>>
>>> @decorate
>>> @typehint(str, int) -> bool
>>> def myfunction(arg1, arg2):
>>>
>>>
>>> and be annoyed or perplexed by the syntax error.
>>>
>>> Some syntax will be a bug magnet. This is one.
>>
>> Your argument is weak here. If the interpreter cannot
>> distinguish between "@typehint ..." and "@ ..."
>
> Thank you for demonstrating my point for me.
>
> The difference is not
>
> @typehint(...)
> def func(...):
>
> versus any other decorator, but the STRING:
>
> "@typehint(...)"
>
> being used where a decorator would normally be expected.
>
> If a genius of the degree like Rick can be fooled, what hope do ordinary
> mortals have?
>

So Rick is having a bad hair day, hence using fuzzy logic?  Ooh, that 
one is so bad even my stomach hurts :)

-- 
My fellow Pythonistas, ask not what our language can do for you, ask
what you can do for our language.

Mark Lawrence




More information about the Python-list mailing list