Ok, here are some easy points. PyBinding came with this script:
def IsNotNull(value):
return value is not None
It is close, but what I want is this.
bool IsNotNullOrEmpty(string value) {
return (value != null) && (value.Length > 0 );
}
Ok, here are some easy points. PyBinding came with this script:
def IsNotNull(value):
return value is not None
It is close, but what I want is this.
bool IsNotNullOrEmpty(string value) {
return (value != null) && (value.Length > 0 );
}
To check if a string is empty you would use len
. Try this:
def IsNotNull(value):
return value is not None and len(value) > 0
not not
. –
Redolent You should not be doing this in a function. Instead you should just use:
if someStringOrNone:
repr()
of the value so we can take a look. –
Systematic If it's IronPython, then why not use the default implementation of IsNullOrEmpty from System.String?
import clr
clr.AddReference('System')
import System
System.String.IsNullOrEmpty('') # returns True
System.String.IsNullOrEmpty(None) # returns True
System.String.IsNullOrEmpty('something') # returns False
def IsNotNullString(s):
return bool(s)
i think,
if IsNotNull(value) {
is equivalent to
if not value:
for strings. so i think the function is not necessary in python.
if not value or len(value)==0:
return True
else:
return False
Try this one. I recommend you to read this book:https://play.google.com/store/apps/details?id=com.gavin.gbook
© 2022 - 2024 — McMap. All rights reserved.