Total newbie python question. I find myself having to write to the following code
s: str
if s is None or len(s) <= 0
to check for string validation.
I finally wrote a tiny function to do that for me.
Is there a more pythantic way of doing this?
Total newbie python question. I find myself having to write to the following code
s: str
if s is None or len(s) <= 0
to check for string validation.
I finally wrote a tiny function to do that for me.
Is there a more pythantic way of doing this?
The string will be "truthy" if it is not None or has len > 0. Simply do the following check:
if s:
print("The string is valid!")
If your real goal is to find out if s is a string, you can use isinstance().
isinstance(s,str)