Clickable hyperlinks

Dan Strohl D.Strohl at F5.com
Tue Jan 3 04:34:56 EST 2017


The best bet (unless you know that you are outputting to a specific place, like 
html or excel) is to always include the "https://" or "http://" since most of 
the consoles / terminals that support clickable links are parsing them based on 
"seeing" the initial "http://".  If your output just looks like 
"mysite.com/coolpage.html", many systems will simply ignore them.

At one point I had made a class that you could pass the link to, and then you 
could request different output based on your needs... so basically something 
like:

>> url = url_class("mysite.com/coolpage.html")
>> print(url)
"http://mysite.com/coolpage.html")
>> print(url.plain)
"mysite.com/coolpage.html"
>> print(url.html('My Site"))
'<a href="http://mysite.com/coolpage.html">My Site</a>'

(or whatever... I think I actually just sub-classed url.parse or something)




-----Original Message-----
From: Python-list [mailto:python-list-bounces+d.strohl=f5.com at python.org] On
Behalf Of Devin Jeanpierre
Sent: Tuesday, January 03, 2017 12:57 PM To: python at deborahswanson.net
Cc: comp.lang.python <python-list at python.org>
Subject: Re: Clickable hyperlinks

Sadly, no. :(  Consoles (and stdout) are just text, not hypertext. The way to 
make an URL clickable is to use a terminal that makes URLs clickable, and print 
the URL:

print("%s: %s" % (description, url))

-- Devin

On Tue, Jan 3, 2017 at 11:46 AM, Deborah Swanson <python at deborahswanson.net> 
wrote:

> Excel has a formula:
>
> =HYPERLINK(url,description)
>
> that will put a clickable link into a cell.
>
> Does python have an equivalent function? Probably the most common use
> for it would be output to the console, similar to a print statement,
> but clickable.
>
> --
> https://mail.python.org/mailman/listinfo/python-list
>
--
https://mail.python.org/mailman/listinfo/python-list



More information about the Python-list mailing list