3 ms·
I'll take it one step further - I don't think I've ever used `is` for anything other than comparisons to `None`.
by yen223 9y ago
I'll take it one step further - I don't think I've ever used `is` for anything other than comparisons to `None`.
- bobbyi_settv 9y agoIt's useful when you want a sentinel object and you don't want to use None as the sentinel because it is a valid value. Some discussion here: http://www.ianbicking.org/blog/2008/12/the-magic-sentinel.html http://www.ianbicking.org/blog/2008/12/the-magic-sentinel.ht...
- gvx 9y ago`is` is also useful for things like detecting cycles for walking object graphs. But I'd estimate 99% of the times I've used `is` was for comparisons to `None`, and 90% of the rest of times for comparisons to other sentinel values.