Welcome, guest | Sign In | My Account | Store | Cart
# Ensure variable is defined
try:
    x
except NameError:
    x = None

# Test whether variable is defined to be None
if x is None:
    some_fallback_operation()
else:
    some_operation(x)

History

  • revision 2 (22 years ago)
  • previous revisions are not available