I'm not sure if this is purely a shapefile "phenomenon" (I rarely if ever mess with GDB--they have nullable fields at any rate), but cells that appear to be blank are not really blank.
This can be shown by adding a blank field and then running a field calculator on it, setting the values to
"". If you look at the values afterwards, they are actually being stored as single spaces, which can be seen via a cursor or during an edit session.
You can go and delete the space, save your edits, and it will still come back.
If the above code seems to be failing for this reason, you'll need to make a slight adjustment:
if not myField:
elif myField == " ":
If you know that the cells are stored as a true "blank cell" then you can use ternary operators:
return someValue if not myField else MyField
or if some cells are stored as a single space:
return someValue if myField == " " else MyField