Clickable hyperlinks

Steve D'Aprano steve+python at pearwood.info
Tue Jan 3 19:56:17 EST 2017


On Wed, 4 Jan 2017 10:32 am, Deborah Swanson wrote:


> The GUI consoles I have are in Pycharm, the IDLE that comes with
> Anaconda, and Spyder. PyCharm and IDLE both ask for internet access when
> I open them, so they're capable of opening links, but whether that means
> their output space is capable of handling clickable links I don't know.
> 
> I do know printing a full url with the %s specifier or entering a url
> and clicking enter just gives you the plain text url. Obviously, not all
> GUI consoles are enabled recognize and make clickable links from
> correctly formatted urls.
> 
> I was hoping there was some functionality in python to make clickable
> links. Could be a package, if the core language doesn't have it.

Unfortunately there is no such thing as an application-
independent "clickable link".

Excel can make clickable links, because it only has to deal with a single
suite of related applications: Excel, Word, and the rest of Microsoft
Office. Likewise LibreOffice.

But Python has to deal with an infinite number of potential or hypothetical
consoles, and there is no standard for "clickable links" that all, or even
most, consoles understand.

Python can't force the console to treat something as a clickable link, if
the console has no capacity for clickable links. Nor can Python predict
what format the console uses to recognise a link.

The best you can do is to experiment with a couple of simple formats and see
which, if any, your console understands:

# HTML
<a href="http://www.example.com">Example.</a>

# URL in angle brackets
Example <http://www.example.com>

# URL alone
http://www.example.com

# I can't remember what these are called
<url:http://www.example.com>

# Markup
[Example](http://www.example.com)

# Rest
`Example <http://www.example.com>`_





-- 
Steve
“Cheer up,” they said, “things could be worse.” So I cheered up, and sure
enough, things got worse.




More information about the Python-list mailing list