'Python or condition in "if" [closed]
def get_profile_num_of_posts():
res = None
if MAYBE:
res = 10
num_of_posts = get_profile_num_of_posts()
if num_of_posts is None or limit_by_num_of_posts > num_of_posts:
return False, False
Is it fine to check for None (num_of_posts is None), and Value int
(limit_by_num_of_posts > num_of_posts) on the same condition?
Since if num_of_posts is None and the second condition will be evaluated it will raise an error.
UPDATE: Ok it is fine according to "Short-circuit_evaluation" which evaluate the first condition ....
What about "coding conventions" ?
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
| Solution | Source |
|---|
