Skip to main content
The 2026 Annual Developer Survey is live— take the Survey today!

You are not logged in. Your edit will be placed in a queue until it is peer reviewed.

We welcome edits that make the post easier to understand and more valuable for readers. Because community members review edits, please try to make the post substantially better than how you found it, for example, by fixing grammar or adding additional resources and hyperlinks.

3
  • while preference is your full right, not k in d could confuse a novice as (not k) in d, while k not in d has no ambiguity Commented Dec 2, 2012 at 23:59
  • I would even argue that it is the 'pythonic' way as not in is listed as an operator. Commented Dec 3, 2012 at 0:09
  • Yeah, I think my preference probably comes from learning other languages first, where for something like a containment test you wouldn't have operators for this so you would do something like !a.contains(b). not in may be more pythonic, I just find the concept of two word operators more confusing than using an inverse on a boolean expression. Commented Dec 3, 2012 at 0:24

lang-py