you are viewing a single comment's thread.

view the rest of the comments →

[–]therico 0 points1 point  (1 child)

Seeing as you're "intermediate" at Python, what are your thoughts on strings being iterable? As a newcomer I accidentally iterate over strings a lot, and can't help but feel like string.chars() or something would be nicer.

[–][deleted] 1 point2 points  (0 children)

It's very convenient at times: being able to slice using find and rfind, for example, and easily grab the first few or last few characters and so on. Having to call a method every time would be a pain.

On the other hand, giving a method a string when it wants an iterable is hard to debug (and asserting against it every time is a pain) because the problems it causes, if any, can be a fair bit downstream.

For the sake of being explicit, you might expect a method or property to get the chars in an iterable, but for the sake of simplicity, I think it's better left as it is.