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? -- Steven -- https://mail.python.org/mailman/listinfo/python-list