Search This Blog

python: conditional expression


x = true_value if condition else false_value

if isinstance(s, basestring if sys.version_info[0]<3 else str):
print('It is a str.')

see also

No comments:

Post a Comment