On Thu, Oct 17, 2019 at 02:08:56PM +0200, Anders Hovmöller wrote: > Well obviously never with literals. But most cases of multiplication > aren't with literals. So how can you get a type error when doing > > a*b > > is the real question.
Actually, the real question is, why are you using such clearly unsuitable and non-descriptive variable names and blaming the confusion caused by poor names on the syntax? Borrowing from the PEP, how would you get a type-error from these? width + margin prefix + word If you did, the cause would clearly be a bug in your code, not the fault of the syntax. In my experience, the most common use for the repetition operator in strings involves a single, literal, character: dashes = '-'*count > And the answer is now obvious: any time the programmer thinks a and b > are numbers but they are not. And this is a fault of the syntax, how? If repetition was spelled: a.repeat(b) and the programmer thought a was a string, when it was actually a float, and thought b was an int, but it was actually None, would you conclude that "method calls are a mistake" because they cause type errors? I'm sure you would agree with me that this is a bogus argument. Type errors are a sign of a bug in the code regardless of the spelling: you think a value has a different type than it actually has't. If it is a bogus argument for method calls, it is a bogus argument for operators. > That's a logical type error that now propagates and it's very hard to > track down the offending line when you eventually end up with a crash > in a different module because And that's an argument against any form of type polymorphism. I expected a list, but got a string, and len(a) didn't raise TypeError therefore "functions are a mistake". -- Steven _______________________________________________ Python-ideas mailing list -- python-ideas@python.org To unsubscribe send an email to python-ideas-le...@python.org https://mail.python.org/mailman3/lists/python-ideas.python.org/ Message archived at https://mail.python.org/archives/list/python-ideas@python.org/message/O5LGFBSRYSDA4OFKX5ATMKNOWIJQTM5T/ Code of Conduct: http://python.org/psf/codeofconduct/