Hacker News new | past | comments | ask | show | jobs | submit login

They should have made the analogous inverse operation: '1234' / 2 = ['12', '34']



That's not the inverse of the multiplication though. The inverse would be '33' / 2 = '3', and '1234'/2 should then probably raise a ValueError.


I was more expecting '1111' / 4 = '1'. This would be the inverse operation. However, it opens up even more questions like what to do if your string has mixed values etc


The string multiplication is about _joining_ strings, the inverse is about _splitting_ them in several parts. It's only confusing because the * appends the string to itself, the / is actually very clear.


Disagree. The inverse "string" * value is logically splitting, and then collapsing the repeated values. The logical split can be omitted, but the collapsing cannot.


Naming is hard they say




Join us for AI Startup School this June 16-17 in San Francisco!

Guidelines | FAQ | Lists | API | Security | Legal | Apply to YC | Contact

Search: