0

This question is frivolous but I consider it a quality-of-life/Python trivia issue.

I find myself writing x is not None often. Is there a clever semantically equivalent way of writing that more succinctly? Or is this an example of the "only one way" maxim in action?

PEP 20, The Zen of Python

There should be one--and preferably only one--obvious way to do it.

If anyone knows something magic, great. And if you have tried and failed to figure something out, let yourself be counted.

Jamborino
  • 161
  • 9
  • Related. http://stackoverflow.com/questions/11166748/identity-versus-equality-for-none-in-python?rq=1 as well as http://stackoverflow.com/questions/14247373/python-none-comparison-should-i-use-is-or?rq=1 – OneCricketeer Nov 13 '16 at 07:23

1 Answers1

0

No, there is no more succinct way to make this comparison than using the is operator.

augurar
  • 12,081
  • 6
  • 50
  • 65