4 ms·
> Using * on a sequence wouldn't get past code review On a mutable sequence. Or anything mutable. [] being a sequence is not the issue here. If you work with
by maweki 3y ago
> Using * on a sequence wouldn't get past code review
On a mutable sequence. Or anything mutable. [] being a sequence is not the issue here.
If you work with immutable stuff, * is really not an issue.
- boxed 3y agoIt's not great though. I do use it to repeat strings but it should have been a method and not weirdly overloading *. This type of misuse of operator overloading is why people from a C++ background think operator overloading is evil. In python it's mostly ok, due to a more restrained culture, but this is a good example of when it's bad.
- maweki 2y agoIt's not weirdly overloaded. 'a'*3 == 'a'+'a'+'a'