On Tuesday, June 19, 2018 at 5:21:25 AM UTC-5, Chris Angelico wrote: > On Tue, Jun 19, 2018 at 8:12 PM, Steven D'Aprano > <steve+comp.lang.pyt...@pearwood.info> wrote: > > On Mon, 18 Jun 2018 11:34:40 -0700, Jim Lee wrote: > > > >> On 06/18/2018 11:18 AM, Chris Angelico wrote: > >>> What, fundamentally, is the difference between type hints and > >>> assertions, such that - in > >>> your view - one gets syntax and the other is just comments? > >> Type hints are just that - hints. They have no syntactic meaning to the > >> parser, and do not affect the execution path in any way. Therefore, they > >> are effectively and actually comments. The way they have been > >> implemented, though, causes noise to be interspersed with live code and, > >> as others have said, are difficult to remove or ignore. > > > > So let me get this straight... > > > > Using annotations is evil, because it intersperses noise with live code: > > > > def function(argument: int, > > flag: bool, > > sequence: list) -> str: > > ... > > > > > > But using comments is great, because it doesn't: > > > > def function(argument, # type=int, > > flag, # type=bool, > > sequence, # type=list): # type=str > > ... > > > > > > Okay, I'm glad we cleared that up. > > > > Isn't it nice how comments, being terminated exclusively by > end-of-line, allow the introduction of subtle bugs? Let's see how many > people spot the (presumably deliberate) bug in Steve's code here.
It wasn't deliberate, Chris. But if Steven "presumably" wanted to show us why hanging comments are a code smell that most professional programmers will avoid, well, he certainly excelled at that, didn't he? -- https://mail.python.org/mailman/listinfo/python-list