Skip to content

Instantly share code, notes, and snippets.

@billyshambrook
Created March 24, 2015 14:22
Show Gist options
  • Save billyshambrook/6745e0b9c88983ff612c to your computer and use it in GitHub Desktop.
Save billyshambrook/6745e0b9c88983ff612c to your computer and use it in GitHub Desktop.
Check if string is a URL or not
import urlparse
def is_url(str_):
"""
Returns True if string is a URL.
>>> is_url('not a url')
False
>>> is_url('http://www.example.com')
True
>>> is_url('s3://bucket/hello')
True
"""
return bool(urlparse.urlparse(str_).scheme)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment