0

I'm writing my first Python web application. My code is difficult because it often needs to treat fields separately if they contain a blank value object.propery = '' and a Null value object.property = None.

Is there a simple way of dealing with these two values as one? I've noticed some languages have a isNullorEmpty() function. I've also noticed that if a DB field is set to contain numbers then assigning a blank value to the field just makes it Null.

kwoxer
  • 3,734
  • 4
  • 40
  • 70
rcx935
  • 217
  • 5
  • 15
  • 1
    Does this answer your question? [null object in Python?](https://stackoverflow.com/questions/3289601/null-object-in-python) – L.Grozinger Apr 12 '20 at 10:58

1 Answers1

0

You could just use

if object.property:
    ....

This will work for empty strings and None.

BeneSim
  • 80
  • 5