How to avoid for-in looping over None in Python
I know I can add some if blocks around to avoid this problem, but I am looking for a best practice or good/nice way to handle this kind of programming problem. I am looping through the result of a function, without storing the result first in a separate variable; something like this: for item in mycustimitemgetter.itter(): dosomething() The itter function is returning None instead of an empty list [], and Python throws an exception per None. This is correct python behavior and nothing's wrong with it. But I'm looking for a best practice solution to: a) keep the code clean and simple (not stori
0 upvotes
View original discussion ↗
Comments
Sign in or sign up to comment and upvote.
No comments yet.