Why does list.index throw an exception, instead of using an arbitrary value (for example, -1
)? What's the idea behind this?
To me it looks cleaner to deal with special values, rather than exceptions.
EDIT: I didn't realize -1
is a potentially valid value. Nevertheless, why not something else? How about a value of None?
See Question&Answers more detail:
os 与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…