Skip to content

Instantly share code, notes, and snippets.

@davidcorbin
Created August 5, 2014 20:47
Show Gist options
  • Save davidcorbin/84ebb032ebcce013327f to your computer and use it in GitHub Desktop.
Save davidcorbin/84ebb032ebcce013327f to your computer and use it in GitHub Desktop.
Test if string
thisint = 1
thisstring = "asdf"
if isinstance(thisstring, basestring) :
print thisstring + " is a string"
else:
print thisstring + " is an int"
if isinstance(thisint, basestring) :
print str(thisint) + " is a string"
else:
print str(thisint) + " is an int"
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment