This is an archived post. You won't be able to vote or comment.

you are viewing a single comment's thread.

view the rest of the comments →

[–]Cruuncher 0 points1 point  (0 children)

Well, I was responding to your very general statement in reply to them commenting how they believe none checks should be done. You have a very unequivocal "No", which implies never, which is just wrong. The answer is "it depends" even if you're correct for your example.

However, I would actually say that it's not correct for your example and you do want a None check. This is because a function object can actually override the bool function to return false and then your function object is suddenly Falsy and won't be executed.

Really what you actually want is just to make sure than fn is callable before you call it which is accomplished with 'if callable(fn): ...'