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

forms - Secure PHP File Upload Script -

PHP: Exploding array elements -

java - How do I override the spring framework version in Spring Batch? -