|
|
|
|
|
by dragonwriter
798 days ago
|
|
I mean, there is no reason Python couldn't special case something that looked like an operator call into shorthand for a comprehension instead of shorthand for a method call, other than the fact that it would make the parser more complex and make it harder to understand the language. It would be bad for this case, though. As confusing as the particular case of: [[]] * 4
might be to people who haven't learned how it works, list multiplication doesn't just apply to single element lists, and is useful and usefully distinct from what people are suggesting the behavior should be for the operation based on this one case. |
|
Besides, that still doesn't help with the case of
where there is no literal list expression.