Created
September 12, 2011 04:36
-
-
Save dmitric/1210592 to your computer and use it in GitHub Desktop.
linkify
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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