git.net

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]# how to let argument be optional falling back to certain integer

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

I just wrote def f(y, N, k = None): k = k or (N - 1) return k I was surprised to find out that 0 == False, so f(7, 31, 0) produces 31. I'd like 0 to be a valid choice for k. How do you guys let k be an optional argument such that it defaults to N - 1? Thank you.

- Prev by Date:
**How to test?** - Next by Date:
**how to let argument be optional falling back to certain integer** - Previous by thread:
**why same ctypes code runs on win7, but not on win10?** - Next by thread:
**how to let argument be optional falling back to certain integer** - Index(es):