Hacker Newsnew | past | comments | ask | show | jobs | submitlogin

I'll take it one step further - I don't think I've ever used `is` for anything other than comparisons to `None`.


It'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.ht...


`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.




Guidelines | FAQ | Lists | API | Security | Legal | Apply to YC | Contact

Search: