There is no such thing as "returning nothing" in Python. Every function returns some value (unless it raises an exception). If no explicit return
statement is used, Python treats it as returning None
.
So, you need to think about what is most appropriate for your function. Either you should return None
(or some other sentinel value) and add appropriate logic to your calling code to detect this, or you should raise an exception (which the calling code can catch, if it wants to).
与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…