Same with dictionaries, iterators (will consume the iterator!), and anything else that has a length.
I’ve actually had the string instead of list issue a number of times, because sometimes things get off and it’s hard to track down where things went wrong.
For this reason, I think type hints are the way to go. Use them consistently w/ a static analysis tool like pyright and you’ll catch a lot of these issues before running into cryptic error messages.
foo = “potatoes!”
len(foo)
will give you the number of characters in the string. It’s not a surefire way to find a list at all!
Same with dictionaries, iterators (will consume the iterator!), and anything else that has a length.
I’ve actually had the string instead of list issue a number of times, because sometimes things get off and it’s hard to track down where things went wrong.
For this reason, I think type hints are the way to go. Use them consistently w/ a static analysis tool like
pyright
and you’ll catch a lot of these issues before running into cryptic error messages.