How to guard against nulls in python -


in python, how check if string either null or empty?

in c# have string.isnullorempty(some_string)

also, i'm doing regex like:

p = re.compile(...)  = p.search(..).group(1) 

this break if group doesn't have @ index 1, how guard against ? i.e. how re-write 2 lines safely?

just check it. explicit better implicit, , 1 more line won't kill you.

a = p.search(...) if not none:     # ... 

Comments

Popular posts from this blog

python - Scipy curvefit RuntimeError:Optimal parameters not found: Number of calls to function has reached maxfev = 1000 -

c# - How to add a new treeview at the selected node? -

java - netbeans "Please wait - classpath scanning in progress..." -