Skip to content

Instantly share code, notes, and snippets.

@dmitric
Created September 12, 2011 04:36
Show Gist options
  • Save dmitric/1210592 to your computer and use it in GitHub Desktop.
Save dmitric/1210592 to your computer and use it in GitHub Desktop.
linkify
def linkify(words, urls):
if isinstance(words, basestring) or not isinstance(words, (list, tuple)):
if isinstance(urls, basestring) or not isinstance(urls, (list, tuple)):
return linkify([words], [urls])
else:
return words
else:
html_links = ['<a href="{1}">{0}</a>'.format(word,url)
for word, url in zip(words, urls)
if word is not None and url is not None]
return ", ".join(html_links)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment