Clickable hyperlinks

Deborah Swanson python at
Tue Jan 3 02:04:36 EST 2017

Steve D'Aprano wrote, on January 03, 2017 4:56 PM

> 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".

I'm getting that.

> 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="">Example.</a>
> # URL in angle brackets
> Example <>
> # URL alone
> # I can't remember what these are called <url:>
> # Markup
> [Example](
> # Rest
> `Example <>`_
> --
> Steve
> "Cheer up," they said, "things could be worse." So I cheered
> up, and sure enough, things got worse.

I tried all of your examples in IDLE, and they all get syntax errors. I'd 
expect the same from PyCharm, though I didn't try it.

I think I need to write a class to do it in a particular application, 
preferably in PyCharm, though I'd need some kind of internet access engine to 
do it anywhere. I can look up how Firefox does it, pretty sure I have that 
somewhere. Maybe there's a way...

Maybe it's a stupid idea, but originally I wanted to output links and click on 
them while I was still debugging in PyCharm, without having to save the csv and 
reopen it in Excel, to see what was in a listing* while I was still debugging. 
PyCharm does have links in its console output that take you to positions in the 
code when you click on them, so it seems like all the basic infrastructure is 
there. I just have to figure out how to do it for internet urls that I output.

* listing is a real estate listing with a url, part of a project I'm
working on, in case you haven't read the "Cleaning up conditionals" thread.

More information about the Python-list mailing list