If you missed the entry about Add links to text with URLs I suggest you read that first. This script has now been improved with bug fixes thanks to David Otton and Flump Cakes.

Download: addhrefs-0.4.tgz
It does not come with a nice installer because I don't think it belongs to the generic Python library anyway. If you want to use it, copy the file addhrefs.py to somewhere useful.

This is how it works:


>>> from addhrefs import addhrefs
>>> t='''Hello www.peterbe.com
and peterbe.com go to http://user:pass@google.ca
send to mail@email.com 
or <here@there.com>'''
>>> print addhrefs(t)
Hello <a href="https://www.peterbe.com">www.peterbe.com</a>
and peterbe.com go to <a  href="http://user:pass@google.ca">http://user:pass@google.ca</a>
send to <a href="mailto:mail@email.com">mail@email.com</a> 
or <<a  href="mailto:here@there.com">here@there.com</a>>

The example might be confusing since the Python code highlighter tries to do what addhrefs does.

UPDATE: Link to addhrefs-0.4.tgz didn't work before. Now it does.

Comments

Bob Marley

Hello? people! visit to my site!

Justin

I don't know how I found this, but it's strange. Thanks

Your email will never ever be published.

Previous:
XHTML Transitional versus Strict November 5, 2004 Web development
Next:
Indent text like email clients do November 11, 2004 Python
Related by category:
Claude Opus is 10x faster than OpenAI GPT 5 at non-streaming completions July 24, 2026 Python
Best Django Redis configuration for speed and size July 19, 2026 Python
How to use a list/tuple/array in Django with a raw SQL cursor July 14, 2026 Python
Using AI to rewrite blog post comments November 12, 2025 Python
Related by keyword:
Add links to a text with URLs November 3, 2004 Web development
Google is blind January 24, 2005 Web development
Control comment spam April 5, 2005 Python
Breaking usability principles for usability February 10, 2004 This site