Re: Choosing a Python IDE. what is your Pythonish recommendation? I do not know what to choose.
Tim Johnson writes: > * Antonio Caminero Garcia [170102 20:56]: >> Guys really thank you for your answers. Basically now I am more >> emphasizing in learning in depth a tool and get stick to it so I >> can get a fast workflow. Eventually I will learn Vim and its >> python developing setup, I know people who have been programming >> using Vim for almost 20 years and they did not need to change >> editor (that is really awesome). > > Bye the way, one thing I like about the GUI based vim is that it > supports tabs, where emacs does not. M-x package-install tabbar -- https://mail.python.org/mailman/listinfo/python-list
Re: Clickable hyperlinks
"Deborah Swanson" writes: > > I didn't try printing them before, but I just did. Got: > print([Example](http://www.example.com) > > SyntaxError: invalid syntax (arrow pointing at the colon) > With respect, if you typed that at python then it's probably a good idea to take a step back and work through the excellent tutorial. https://docs.python.org/3/tutorial/ -- https://mail.python.org/mailman/listinfo/python-list
RE: Clickable hyperlinks
Michael Torrie wrote, on January 03, 2017 8:05 PM > > On 01/03/2017 08:46 PM, Deborah Swanson wrote: > > Actually it is, or at least it doesn't happen in all email readers. > > Mine, for instance, never breaks up threads. > > Mine doesn't either, which illustrates the issue. This > message, for example appears under a long thread that started > out life as "mentor training python Romania with > certification" and then changed to "Cleaning up conditionals" > and then changed to "Clickable hyperlinks." All in one > thread. My client doesn't break them up because they all tie > together via the message-id header. > > And most of us would not like our client to break a thread > just because the subject changes. Often in long conversations > there are twists and turns in the discussion and sometimes > side-paths are explored, and the subject often is changed to > reflect this. With a truly threaded email reader (one that > shows a tree of messages, not just chronological order), this > works out very well. So if a discussion has a natural > evolution into various other topics, it is often considered > okay to just change the subject but continue the thread. > Other times, it's better to start a new thread. Where that > line is is hard to say! > > > I did say in the message you're replying to that I will try to > > remember to start new threads with brand new messages. > (Even though I > > think pipermail's behavior is a bug, that's what many > people read the > > list > > from.) > > Sounds good. > > I don't know of anyone that reads on the pipermail archive, > except in response to web searches. Most people use clients > of some kind, NNTP or email. And those that group messages > according to message-id (most clients except for ones that > try to be smart like Gmail web or Outlook) will show all the > topics I mentioned before as one giant thread, which is by > design (that's what message-id headers are for). I suppose. Times change of course, which always suits some and not others. Personally, I think putting messages that have different titles all in one thread is a bad design, but as I've said a couple of times now I intend to comply with the new rules. But compliance doesn't imply agreement. I prefer the old system, which ordered threads by titles, but there's obviously no pleasing everyone on this issue. -- https://mail.python.org/mailman/listinfo/python-list
RE: Clickable hyperlinks
Steven D'Aprano wrote, on January 03, 2017 9:40 PM
>
> On Wednesday 04 January 2017 15:46, Deborah Swanson wrote:
>
> > Steven D'Aprano wrote, on January 03, 2017 8:04 PM
> [...]
> >> Of course you have to put quotes around them to enter them in your
> >> source code. We don't expect this to work:
> >>
> >> print(Hello World!)
> >>
> >>
> >> you have to use a string literal with quotes:
> >>
> >> print('Hello World!')
> >>
> >>
> >> Same for all of the above.
>
> > I didn't try printing them before, but I just did. Got:
> >
> print([Example](http://www.example.com)
> >
> > SyntaxError: invalid syntax (arrow pointing at the colon)
>
> You missed the part where I said you have to put them in quotes.
>
> Like any other string in Python, you have to use quotation
> marks around it for
> Python to understand it as a string. None of these things will work:
>
> print( Hello World! )
>
> print( What do you want to do today? )
>
> print( 3 2 1 blast off )
>
> print( http://www.example.com )
>
>
> This isn't specific to print. This won't work either:
>
> message = Hello World!
>
> In *all* of these cases, you have to tell Python you're
> dealing with a string,
> and you do that with quotation marks:
>
> message = "Hello World!"
> print( 'What do you want to do today?' )
> count_down = '3 2 1 blast off'
> url = 'http://www.example.com'
>
>
>
>
> --
> Steven
Thanks, Steven. Yes, of course if you want to print strings you must
enclose them in quotes. I think you learn that in Week 1 of any
introductory course on Python.
But we aren't trying to print strings here, the point is to produce
clickable links. I didn't enclose them with quotes because I didn't see
any point in printing plain text when I wanted clickable links. I
actually didn't understand why you thought I should print them, but it
never would have occurred to me that you wanted me to print out a bunch
of silly plain text strings, apparently just for the heck of it.
At this point, if I pursue this any farther, it will be to look into how
Firefox takes webpage titles and urls out of its sqlite database and
makes objects you can click on to open the webpages. That's the basic
technology I'd need to find a way to talk (write) python into doing.
If it's even worth it. On a practical level it's not worth it, way too
much work for the teensy advantage of having it to use. It might be some
giggles to figure out how to do it and maybe I will sometime just for
funsies.
My original question was whether python had anything to provide this
functionality, and the answer appears to be a resounding NO!!!
Answer received, and thanks to all who contributed.
--
https://mail.python.org/mailman/listinfo/python-list
Re: Screwing Up looping in Generator
On Wed, 4 Jan 2017 01:09 pm, Sayth Renshaw wrote: > Untested as i wrote this in notepad at work but, if i first use the > generator to create a set of filenames and then iterate it then call the > generator anew to process file may work? It "may" work. Or it "may not" work. It is hard to tell because we don't have enough context to understand your code. Let me see if I can guess what you are doing: > Good idea or better available? > > def get_list_of_names(generator_arg): > name_set = set() > for name in generator_arg: > base = os.path.basename(name.name) > filename = os.path.splitext(base)[0] > name_set.add(filename) > return name_set What does "generator_arg" do? Since you iterate over it, it could be a list, a tuple, any other sequence, or an iterator. Why does it have to be a generator? What is "name.name"? I *think* that your intention is to take a list of objects that hold filenames: ["C://My Documents/data.txt", "C://My Documents/folder/image.jpg", "C://file.txt", "D://installer.exe", "E://folder/image.gif"] strip off the path, strip off the file extensions, remove any duplicates, giving: set(["data", "image", "file", "installer"]) (Notice that image.jpg and image.gif count as duplicates.) If that is what you want, then I think get_list_of_names will work, except: - the name is WRONG: it returns a set, not a list; - the name does not describe what the function does; - there's no documentation - the name of the argument is misleading, it doesn't have to be a generator. Other than that, I think the code does what I think you want. > for file_name in name_set: > directory = "output" > with open(os.path.join(directory, filename, 'w', newline='') as > csvf: > for file in rootobs: > # create and write csv Your indentation is wrong. What's "rootobs"? The code you show here does not have enough detail for me to even try to guess what it does. -- Steve “Cheer up,” they said, “things could be worse.” So I cheered up, and sure enough, things got worse. -- https://mail.python.org/mailman/listinfo/python-list
RE: Clickable hyperlinks
On Wed, 4 Jan 2017 08:00 pm, Deborah Swanson wrote: [speaking of threading emails] > I suppose. Times change of course, which always suits some and not > others. Personally, I think putting messages that have different titles > all in one thread is a bad design, but as I've said a couple of times > now I intend to comply with the new rules. But compliance doesn't imply > agreement. I prefer the old system, which ordered threads by titles, but > there's obviously no pleasing everyone on this issue. Indeed :-) However, as far as I am aware, the use of threading by following the In-Reply-To and References header lines goes back to at least 1982, which makes them pretty old, and certainly pre-dates Gmail and Outlook by many years. They're also official standards which ALL email programs are supposed to follow, so if Gmail and Outlook fail to follow the standard, well, I wouldn't be surprised. I don't absolutely know for a fact that threading in this way is older than threading by subject line, but I'm fairly confident that what you are calling the "new rules" are actually the much older rules. Are there any old-timers here who were using email prior to 1982 that would care to comment? Here's a discussion by Jamie Zawinski, who wrote Netscape Navigator, before it became Mozila and Firefox, so he knows what he's talking about: https://www.jwz.org/doc/threading.html The concept here is not so much that people start a new topic and change the subject, but that sometimes the topic just naturally evolves to the point that a change in subject is sensible. Take this thread for example: the topic has drifted from "Clickable hyperlinks" to talking about email threading. I should be able to change the subject without breaking the thread: Clickable hyperlinks ├─ RE: Clickable hyperlinks │ ├─ Re: RE: Clickable hyperlinks │ └─ RE: Clickable hyperlinks │ └─ Threading [was Re: Clickable hyperlinks] │└─ Re: Threading ├─ RE: Clickable hyperlinks └─ Re: Clickable hyperlinks Adding a "Re:" or "RE" to the subject doesn't change the thread, and neither does changing the subject line in a more substantial way. Of course, I can always *choose* to sort by subject line, or date. Personally I hardly ever sort by thread, so it is no skin off my nose what you do. But when you hit "Reply" to a message, you inherit the "Reference" and "In-Reply-To" headers from the previous message, so at least some people will see it threaded in an existing thread rather than starting a brand new one. -- Steve “Cheer up,” they said, “things could be worse.” So I cheered up, and sure enough, things got worse. -- https://mail.python.org/mailman/listinfo/python-list
RE: Clickable hyperlinks
On Wed, 4 Jan 2017 03:46 pm, Deborah Swanson wrote:
> As I've mentioned in other posts on this thread, I'm now thinking that I
> need to write a class to do this, and find out how Firefox and url aware
> terminals in Linux do it. There must be a way.
A GUI application can interpret text any way it chooses. Firefox takes a
HTML file and renders it, using whatever GUI library it chooses. That GUI
library understands that text like:
Hello World!
should be shown in bold face, and text like:
http://www.example.com";>Example
should be shown as the word "Example" underlined and in some colour, and
when you click on it the browser will navigate to the URL given. Firefox
can do this because it controls the environment it runs in.
Same for Excel, which also controls the environment it runs in.
That's *not* the case for Python, which is at the mercy of whatever console
or terminal application it is running in.
However, you can use Python to write GUI applications. Then it becomes
*your* responsibility to create the window, populate it with any buttons or
text or scroll bars you want, and you can choose to interpret text any way
you like -- including as clickable Hyperlinks.
The bottom line is, there is no "a way" to do this. There are a thousand,
ten thousand, ways to do it. Every web browser, every terminal, every
URL-aware application, can choose its own way to do it. There's no one
single way that works everywhere, but if you are working in a console or
terminal, just printing the URL is likely to be interpreted by the console
as a clickable link:
print("http://www.example.com";)
--
Steve
“Cheer up,” they said, “things could be worse.” So I cheered up, and sure
enough, things got worse.
--
https://mail.python.org/mailman/listinfo/python-list
RE: Clickable hyperlinks
On Wed, 4 Jan 2017 08:32 pm, Deborah Swanson wrote:
> Thanks, Steven. Yes, of course if you want to print strings you must
> enclose them in quotes. I think you learn that in Week 1 of any
> introductory course on Python.
>
> But we aren't trying to print strings here, the point is to produce
> clickable links. I didn't enclose them with quotes because I didn't see
> any point in printing plain text when I wanted clickable links. I
> actually didn't understand why you thought I should print them, but it
> never would have occurred to me that you wanted me to print out a bunch
> of silly plain text strings, apparently just for the heck of it.
What we have here is a failure to communicate :-)
I apologise for ruffling your feathers, but its difficult to judge another
person's level of knowledge. In someways you're obviously quite
knowledgeable about Python, but in other ways you're still learning (as we
all are!) and I'm afraid I may have misjudged exactly what your level of
knowledge was. Sorry about that.
I'm not suggesting that you print "silly plain text strings" just for the
heck of it. You've asked how to get a clickable link using Python. There is
only one way I know of to get a clickable link using Python:
Write out a link as plain text to another application which then interprets
the plain text as a clickable link.
You *might* be able to get clickable links in Python by writing an entire
GUI application, using (say) the tkinter library, or one of the third-party
GUI libraries like wxPython, kivy, pyqt, or others, but I haven't a clue
how. But even there, your links will start off as text, which means you
will still need to surround them with quotes to make them strings.
Aside: you've actually raised a fascinating question. I wonder whether there
are any programming languages that understand URLs as native data types, so
that *source code* starting with http:// etc is understood in the same way
that source code starting with [ is seen as a list or { as a dict?
But back to your problem: short of writing you own GUI application, in which
case you can do *anything you like*, you can:
- write out a HTML file containing the URLs you want, in
tags, then open the HTML file in a web browser and let the web browser
interpret the HTML tags as clickable links;
- write out an Excel spreadsheet, using whatever format Excel expects, open
the spreadsheet in Excel, and let Excel interpret the mystery format as a
clickable link;
- print the URL to the console, and see if the console is smart enough to
interpret it as a clickable link.
I'm sorry that I can't give you a one-sentence answer "just use
such-and-such a function, that does exactly what you want in a
platform-independent manner" :-(
--
Steve
“Cheer up,” they said, “things could be worse.” So I cheered up, and sure
enough, things got worse.
--
https://mail.python.org/mailman/listinfo/python-list
RE: Clickable hyperlinks
Steve D'Aprano wrote, on January 04, 2017 2:09 AM > > On Wed, 4 Jan 2017 08:00 pm, Deborah Swanson wrote: > > [speaking of threading emails] > > > I suppose. Times change of course, which always suits some and not > > others. Personally, I think putting messages that have different > > titles all in one thread is a bad design, but as I've said > a couple of > > times now I intend to comply with the new rules. But compliance > > doesn't imply agreement. I prefer the old system, which ordered > > threads by titles, but there's obviously no pleasing > everyone on this > > issue. > > Indeed :-) > > However, as far as I am aware, the use of threading by > following the In-Reply-To and References header lines goes > back to at least 1982, which makes them pretty old, and > certainly pre-dates Gmail and Outlook by many years. They're > also official standards which ALL email programs are supposed > to follow, so if Gmail and Outlook fail to follow the > standard, well, I wouldn't be surprised. I don't absolutely > know for a fact that threading in this way is older than > threading by subject line, but I'm fairly confident that what > you are calling the "new rules" are actually the much older rules. > > Are there any old-timers here who were using email prior to > 1982 that would care to comment? > > > Here's a discussion by Jamie Zawinski, who wrote Netscape > Navigator, before it became Mozila and Firefox, so he knows > what he's talking about: > https://www.jwz.org/doc/threading.html The concept here is not so much that people start a new topic and change the subject, but that sometimes the topic just naturally evolves to the point that a change in subject is sensible. Take this thread for example: the topic has drifted from "Clickable hyperlinks" to talking about email threading. I should be able to change the subject without breaking the thread: Clickable hyperlinks +- RE: Clickable hyperlinks │ +- Re: RE: Clickable hyperlinks │ L- RE: Clickable hyperlinks │ L- Threading [was Re: Clickable hyperlinks] │L- Re: Threading +- RE: Clickable hyperlinks L- Re: Clickable hyperlinks Adding a "Re:" or "RE" to the subject doesn't change the thread, and neither does changing the subject line in a more substantial way. Of course, I can always *choose* to sort by subject line, or date. Personally I hardly ever sort by thread, so it is no skin off my nose what you do. But when you hit "Reply" to a message, you inherit the "Reference" and "In-Reply-To" headers from the previous message, so at least some people will see it threaded in an existing thread rather than starting a brand new one. -- Steve "Cheer up," they said, "things could be worse." So I cheered up, and sure enough, things got worse. Interesting history lesson. I actually wouldn't know which came first, since I've only been online since 1992 (offline computing since 1972). I do know that I've been on a lot of mailing lists like this one since 1992 (remember Fidonet?), some with actively posting members in the thousands. And I have never heard anyone whine and complain about threading issues that had anything to do with the message title until yesterday. So it goes. I'll repeat again that I'll comply with the rules of this group that are brand spanking new to me, and I've been around a corner or two. -- https://mail.python.org/mailman/listinfo/python-list
RE: Clickable hyperlinks
Steve D'Aprano wrote, on January 04, 2017 2:20 AM
>
> On Wed, 4 Jan 2017 03:46 pm, Deborah Swanson wrote:
>
> > As I've mentioned in other posts on this thread, I'm now
> thinking that
> > I need to write a class to do this, and find out how
> Firefox and url
> > aware terminals in Linux do it. There must be a way.
>
>
> A GUI application can interpret text any way it chooses.
> Firefox takes a HTML file and renders it, using whatever GUI
> library it chooses. That GUI library understands that text like:
>
> Hello World!
>
> should be shown in bold face, and text like:
>
> http://www.example.com";>Example
>
> should be shown as the word "Example" underlined and in some
> colour, and when you click on it the browser will navigate to
> the URL given. Firefox can do this because it controls the
> environment it runs in.
>
> Same for Excel, which also controls the environment it runs in.
>
> That's *not* the case for Python, which is at the mercy of
> whatever console or terminal application it is running in.
>
> However, you can use Python to write GUI applications. Then it becomes
> *your* responsibility to create the window, populate it with
> any buttons or text or scroll bars you want, and you can
> choose to interpret text any way you like -- including as
> clickable Hyperlinks.
>
> The bottom line is, there is no "a way" to do this. There are
> a thousand, ten thousand, ways to do it. Every web browser,
> every terminal, every URL-aware application, can choose its
> own way to do it. There's no one single way that works
> everywhere, but if you are working in a console or terminal,
> just printing the URL is likely to be interpreted by the
> console as a clickable link:
>
> print("http://www.example.com";)
>
>
>
>
> --
> Steve
> "Cheer up," they said, "things could be worse." So I cheered
> up, and sure enough, things got worse.
I can appreciate all that and pretty much knew most of it already. At
this point I'm not so much concerned with how to put characters on a
white space that are clickable, we've pretty much established at least a
couple dozen messages ago that there's nothing for python to get hold of
there because of the vast number of places people might want to put
clickable links. (I actually read every message on a thread that
interests me enough to participate.)
I think the entry point to this problem is to find out how to connect to
the internet when you click that link. Then I think the nuts and bolts
of what symbols to put where for a particular target would fall into
place.
--
https://mail.python.org/mailman/listinfo/python-list
RE: Clickable hyperlinks
Steve D'Aprano wrote, on January 04, 2017 2:39 AM
>
> On Wed, 4 Jan 2017 08:32 pm, Deborah Swanson wrote:
>
> > Thanks, Steven. Yes, of course if you want to print strings
> you must
> > enclose them in quotes. I think you learn that in Week 1 of any
> > introductory course on Python.
> >
> > But we aren't trying to print strings here, the point is to produce
> > clickable links. I didn't enclose them with quotes because I didn't
> > see any point in printing plain text when I wanted
> clickable links. I
> > actually didn't understand why you thought I should print
> them, but it
> > never would have occurred to me that you wanted me to print out a
> > bunch of silly plain text strings, apparently just for the
> heck of it.
>
> What we have here is a failure to communicate :-)
>
> I apologise for ruffling your feathers, but its difficult to
> judge another person's level of knowledge. In someways you're
> obviously quite knowledgeable about Python, but in other ways
> you're still learning (as we all are!) and I'm afraid I may
> have misjudged exactly what your level of knowledge was.
> Sorry about that.
>
> I'm not suggesting that you print "silly plain text strings"
> just for the heck of it. You've asked how to get a clickable
> link using Python. There is only one way I know of to get a
> clickable link using Python:
>
> Write out a link as plain text to another application which
> then interprets the plain text as a clickable link.
>
> You *might* be able to get clickable links in Python by
> writing an entire GUI application, using (say) the tkinter
> library, or one of the third-party GUI libraries like
> wxPython, kivy, pyqt, or others, but I haven't a clue how.
> But even there, your links will start off as text, which
> means you will still need to surround them with quotes to
> make them strings.
>
>
> Aside: you've actually raised a fascinating question. I
> wonder whether there are any programming languages that
> understand URLs as native data types, so that *source code*
> starting with http:// etc is understood in the same way that
> source code starting with [ is seen as a list or { as a dict?
>
>
> But back to your problem: short of writing you own GUI
> application, in which case you can do *anything you like*, you can:
>
> - write out a HTML file containing the URLs you want, in href= ... tags, then open the HTML file in a web browser
> and let the web browser interpret the HTML tags as clickable links;
>
>
> - write out an Excel spreadsheet, using whatever format Excel
> expects, open the spreadsheet in Excel, and let Excel
> interpret the mystery format as a clickable link;
>
> - print the URL to the console, and see if the console is
> smart enough to interpret it as a clickable link.
>
>
> I'm sorry that I can't give you a one-sentence answer "just
> use such-and-such a function, that does exactly what you want
> in a platform-independent manner" :-(
>
>
>
>
> --
> Steve
> "Cheer up," they said, "things could be worse." So I cheered
> up, and sure enough, things got worse.
Well, well. People mix and people misunderstand and misjudge each other.
It's the way of things with people. I just needed to tell you how it all
looked from my side. So are we done with that? I certainly hope so.
I'm quite well aware by now that there is no one-sentence answer to my
original question, if there's any coherent answer at all. Them's the
breaks. Live with it or live without it, it doesn't care.
I do appreciate the education I've gotten on this thread about the
issues involved. But I rather imagine that near term anyway, I'll only
be pondering it now and then, and maybe poking around a bit. Who knows,
maybe I'll eventually invent the solution and make my first million
dollars from it. haha, yeah right.
So it goes.
Deborah
--
https://mail.python.org/mailman/listinfo/python-list
Re: Clickable hyperlinks
On Wed, Jan 4, 2017 at 10:43 PM, Deborah Swanson
wrote:
> I'm quite well aware by now that there is no one-sentence answer to my
> original question, if there's any coherent answer at all. Them's the
> breaks. Live with it or live without it, it doesn't care.
Yeah, there's no simple answer; however, you'll find that Python on
many platforms is entirely capable of popping a URL up in the user's
default browser. Check this out:
>>> import antigravity
This uses the 'webbrowser' module, which knows about a number of
different ways to open a browser, and will attempt them all. So if you
can figure out the UI part of things, actually making the link pop up
in a browser isn't too hard; for instance, if you're doing OAuth at
the command line and need the user to go and authenticate, you can
simply webbrowser.open("http://.../";) and it'll DTRT.
ChrisA
--
https://mail.python.org/mailman/listinfo/python-list
Introducing my Python/PyQt5 powered Bing wallpaper open source project
Hello everyone , I'd like to introduce my Python/PyQt5 powered Bing wallpaper open source project. BingNiceWallpapers https://github.com/redstoneleo/BingNiceWallpapers BingNiceWallpapers can get background images from http://www.bing.com/?mkt=zh-CN and set them as your desktop wallpaper by just a single click on system tray icon. For Windows binary installer and more information, please refer to http://mathjoy.lofter.com/post/42208d_7cabcf7 (written in simplified Chinese) Features Changing wallpaper in a single click on system tray icon or after a specified time interval Windows and Linux Gnome desktop support Delete or save the current wallpaper Welcome to help with the project ! -- https://mail.python.org/mailman/listinfo/python-list
Re: Clickable hyperlinks
Deborah - please trim your quoted text.
On 2017-01-04 04:32 AM, Deborah Swanson wrote:
Thanks, Steven. Yes, of course if you want to print strings you must
enclose them in quotes. I think you learn that in Week 1 of any
introductory course on Python.
Closer to minute one. When I investigated Python years ago the first
thing I learned was;
print "Hello, world"
But we aren't trying to print strings here, the point is to produce
clickable links. I didn't enclose them with quotes because I didn't see
any point in printing plain text when I wanted clickable links. I
I'm not sure what your links are composed of but mine all look like
sequences of characters or "strings." It sounds like you are trying to
make URL a first class type like strings. integers, floats, etc. I
can't think of any language that treats URLs as first class objects.
Even HTML needs quotes:
http://...";>Go here
actually didn't understand why you thought I should print them, but it
You want to output them to something. That often involves printing them
to a particular handler.
never would have occurred to me that you wanted me to print out a bunch
of silly plain text strings, apparently just for the heck of it.
Is that really what you got from his message?
At this point, if I pursue this any farther, it will be to look into how
Firefox takes webpage titles and urls out of its sqlite database and
makes objects you can click on to open the webpages. That's the basic
technology I'd need to find a way to talk (write) python into doing.
I can assure you that FF prints the string at some point. It may wrap
it in HTML tags first but printing is what it does. Also, the URLs are
stored as strings. SQLite has no URL type. If it did then it would
still store it as a string somewhere. PostGreSQL would let you create a
URL type if you wanted but you would still need to wrap it in quotes
(single in this case) when you created the entry.
If it's even worth it. On a practical level it's not worth it, way too
much work for the teensy advantage of having it to use. It might be some
giggles to figure out how to do it and maybe I will sometime just for
funsies.
In all the messages in this thread I still don't understand what this
"teensy advantage" is supposed to be. Do you want to be able to do this:
make_web_link(http://...)
instead of:
make_web_link("http://...";)
--
D'Arcy J.M. Cain
System Administrator, Vex.Net
http://www.Vex.Net/ IM:[email protected]
VoIP: sip:[email protected]
--
https://mail.python.org/mailman/listinfo/python-list
Re: Choosing a Python IDE. what is your Pythonish recommendation? I do not know what to choose.
Tried every python ide going, they either grind to a halt or just look messy. Best one I ever used and stick with is drpython, years old, probably not maintained but does everything I want at a blistering speed and just looks perfect. On Mon, Jan 2, 2017 at 11:41 AM +, "Antonio Caminero Garcia" mailto:[email protected]>> wrote: Hello, I am having a hard time deciding what IDE or IDE-like code editor should I use. This can be overwhelming. So far, I have used Vim, Sublime, Atom, Eclipse with PyDev, Pycharm, IntelliJ with Python plugin. The thing with the from-the-scratch full featured IDEs (Eclipse, IntelliJ, Pycharm) is that they look like a space craft dashboard and that unwarranted resources consumption and the unnecessary icons. I want my IDE to be minimalistic but powerful. My screen should be mostly “made of code” as usually happens in Vim, Sublime or Atom. However, Pycharm is really cool and python oriented. The problem with Vim is the learning curve, so I know the very basic stuff, but obviously not enough for coding and I do not have time to learn it, it is a pity because there are awesome plugins that turns Vim into a lightweight powerful IDE-like. So now it is not an option but I will reconsider it in the future, learning little by little. Also, I am not very fan GUI guy if the task can be accomplished through the terminal. However, I don’t understand why people underrate GUIs, that said I normally use shortcuts for the most frequent tasks and when I have to do something that is not that frequent then I do it with the mouse, for the latter case in vim you would need to look for that specific command every time. Sublime is my current and preferred code editor. I installed Anaconda, Git integration and a couple of additional plugins that make sublime very powerful. Also, what I like about sublime compared to the full featured IDEs, besides the minimalism, is how you can perform code navigation back and forth so fast, I mean this is something that you can also do with the others but for some subjective reason I specifically love how sublime does it. The code completion in sublime I do not find it very intelligence, the SublimeCodeIntel is better than the one that Anaconda uses but the completions are not as verbose as in the IDEs. Now, I am thinking about giving a try to Visual Studio Code Edition (take a look, it sounds good https://marketplace.visualstudio.com/items?itemName=donjayamanne.python). I need an editor for professional software development. What would you recommend to me? -- https://mail.python.org/mailman/listinfo/python-list This message is private and confidential and may also be legally privileged. If you have received this message in error, please email it back to the sender and immediately permanently delete it from your computer system. Please do not read, print, re-transmit, store or act in reliance on it or any attachments. British Airways may monitor email traffic data and also the content of emails, where permitted by law, for the purposes of security and staff training and in order to prevent or detect unauthorised use of the British Airways email system. Virus checking of emails (including attachments) is the responsibility of the recipient. British Airways Plc is a public limited company registered in England and Wales. Registered number: 177. Registered office: Waterside, PO Box 365, Harmondsworth, West Drayton, Middlesex, England, UB7 0GB. Additional terms and conditions are available on our website: www.ba.com -- https://mail.python.org/mailman/listinfo/python-list
Re: Clickable hyperlinks
2017-01-04 7:39 GMT-03:00 Steve D'Aprano :
> On Wed, 4 Jan 2017 08:32 pm, Deborah Swanson wrote:
>
> Aside: you've actually raised a fascinating question. I wonder whether
> there
> are any programming languages that understand URLs as native data types, so
> that *source code* starting with http:// etc is understood in the same way
> that source code starting with [ is seen as a list or { as a dict?
> ...
>
Some Smalltalk implementations have something that comes close:
st> 'https://python.org' asUrl retrieveContents
`asUrl` would be a string method returning a URL instance, which also has a
convenient method `retrieveContents` wrapping an http client. Not hard to
do with Python, I think this could be an interesting exercise for a learner.
--
https://mail.python.org/mailman/listinfo/python-list
Re: Clickable hyperlinks
On 2017-01-04 08:44 AM, Rodrigo Bistolfi wrote:
2017-01-04 7:39 GMT-03:00 Steve D'Aprano :
Aside: you've actually raised a fascinating question. I wonder whether
there
are any programming languages that understand URLs as native data types, so
that *source code* starting with http:// etc is understood in the same way
that source code starting with [ is seen as a list or { as a dict?
Some Smalltalk implementations have something that comes close:
st> 'https://python.org' asUrl retrieveContents
But notice that even here the URL has to be defined as a string. To be
a first class object you would need to do something like this:
url = https://python.org/
The only time you would see that is in config files and languages like
shell where everything is a string so no quotes necessary. They are
implied.
`asUrl` would be a string method returning a URL instance, which also has a
convenient method `retrieveContents` wrapping an http client. Not hard to
do with Python, I think this could be an interesting exercise for a learner.
Sure but the issue is, what to do with it. In any case, it's still just
a wrapper around various string methods. You still need to give the
class a string to create the object.
--
D'Arcy J.M. Cain
System Administrator, Vex.Net
http://www.Vex.Net/ IM:[email protected]
VoIP: sip:[email protected]
--
https://mail.python.org/mailman/listinfo/python-list
Re: Screwing Up looping in Generator
On 04/01/17 02:10, Deborah Swanson wrote:
Sayth Renshaw wrote, on January 03, 2017 5:36 PM
So can I call the generator twice and receive the same file
twice in 2 for loops?
Once to get the files name and the second to process?
for file in rootobs:
base = os.path.basename(file.name)
write_to = os.path.join("output",
os.path.splitext(base)[0] + ".csv")
with open(write_to, 'w', newline='') as csvf:
for file in rootobs:
# create and write csv
Cheers
Sayth
I don't see why not, if you let the first one run to completion and then
do it again a second time. Assuming your generator doesn't somehow
delete or modify the file specifications as it yields them. It would be
helpful to see the code for rootobs, if you have it.
Ahem. If Sayth is using the correct terminology and rootobs actually is
a generator (not, say, a list or tuple), then no it won't work. Once a
generator is exhausted, it's exhausted. Besides, the nested for-loops
over the same iterable is a dead giveaway that something is wrong.
--
Rhodri James *-* Kynesim Ltd
--
https://mail.python.org/mailman/listinfo/python-list
Re: Simulating int arithmetic with wrap-around
On Fri, Dec 30, 2016, at 09:47, Steve D'Aprano wrote: > Again, assume both operands are in range for an N-bit signed integer. > What's > a good way to efficiently, or at least not too inefficiently, do the > calculations in Python? I'd do something like: bit_mask = (1 << bits) - 1 # 0x sign_bit = 1 << (bits - 1) # 0x8000 sign_ext = ~bit_mask # ...F def signed(value): if value & sign_bit: return value | sign_ext else: return value & bit_mask def unsigned(value): return value & bit_mask And also avoid doing it on intermediate steps where it can be shown to not affect the result or allow the value to grow too large. -- https://mail.python.org/mailman/listinfo/python-list
Re: Clickable hyperlinks
On 2017-01-03, Deborah Swanson wrote: > Grant Edwards wrote, on January 03, 2017 3:13 PM >> >> On 2017-01-03, Deborah Swanson wrote: >> >> > I'm sorry, I should have said a GUI console because I >> wouldn't expect >> > a text-based console to produce clickable links. >> >> What's a "GUI console"? > 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. Thanks, that's a bit clearer. For those of us from the Unix world "console" means something else. > 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. There is no definition for what a "clickable link" is unless you're sending HTML to a web browser. That means there's no way to create funcationality to make one. -- Grant Edwards grant.b.edwardsYow! I'm not an Iranian!! at I voted for Dianne gmail.comFeinstein!! -- https://mail.python.org/mailman/listinfo/python-list
Re: Choosing a Python IDE. what is your Pythonish recommendation? I do not know what to choose.
> On Jan 4, 2017, at 1:54 AM, Antonio Caminero Garcia > wrote: > > On Tuesday, January 3, 2017 at 4:12:34 PM UTC-8, Dietmar Schwertberger wrote: >> On 02.01.2017 12:38, Antonio Caminero Garcia wrote: >> You did not try Wing IDE? It looks less like a spacecraft. Maybe you >> like it. >> Maybe the difference is that Wing is from Python people while the ones >> you listed are from Java people. > > That sounds interesting. By the look of it I think I am going to give it a > try. > > [byte] > I want editor with those IDE capabilities and git integration, with > optionally cool stuff as for example remote debugging. I use Wing, and I think you will like it. It *is* pythonic, and for what it is worth, offers remote debugging as one of its more recently added features. -Bill -- https://mail.python.org/mailman/listinfo/python-list
Re: Clickable hyperlinks
On 2017-01-04, Michael Torrie wrote: > On my Linux machine, the terminal emulators I've used all make a regular > url printed out into a clickable link (or at least a right-clickable > link). This is just something they try to do with all things that look > like urls. Sometimes it's helpful, often it's annoying. What I have done is defined a window manager root menu entry that opens a web browser on the current text selection. That lets me "click" on a link in any application that suport the standard X11 text-selection mechanism (which is almost all of them). >> 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. > > No, there is not. If you made a full GUI app using a toolkit like > GTK or Qt, you can indeed place hyperlinks on your forms and the > operating system will automatically connect them to the web browser. > But not in text-mode terminal apps. For me it's double-click to select the url in the terminal window or PDF viewer or whaterver, then right-click on the root window and pick the menu entry that says 'Firefox [sel]' or 'Chrome [sel]'. It's a few extra steps, but it works for almostly any application that displays text. -- Grant Edwards grant.b.edwardsYow! Where do your SOCKS at go when you lose them in gmail.comth' WASHER? -- https://mail.python.org/mailman/listinfo/python-list
Re: Choosing a Python IDE. what is your Pythonish recommendation? I do not know what to choose.
* Paul Rudin [170103 23:17]: > Tim Johnson writes: > > > * Antonio Caminero Garcia [170102 20:56]: > >> Guys really thank you for your answers. Basically now I am more > >> emphasizing in learning in depth a tool and get stick to it so I > >> can get a fast workflow. Eventually I will learn Vim and its > >> python developing setup, I know people who have been programming > >> using Vim for almost 20 years and they did not need to change > >> editor (that is really awesome). > > > > Bye the way, one thing I like about the GUI based vim is that it > > supports tabs, where emacs does not. > > M-x package-install tabbar :) Thank you. list-packages is my friend ... -- Tim http://www.akwebsoft.com, http://www.tj49.com -- https://mail.python.org/mailman/listinfo/python-list
Re: Simulating int arithmetic with wrap-around
On 01/03/2017 10:00 PM, Gregory Ewing wrote: Paul Rubin wrote: My first thought is towards the struct module, especially if you want to handle a bunch of such integers at the same time. Or maybe the array module or some combination. Or possibly numpy. Agreed. If you had to do a lot of calculations on arbitrary sized signed/unsigned ints, figuring how to parallelize them into numpy arrays would save you a ton of time. -- Rob Gaddi, Highland Technology -- www.highlandtechnology.com Email address domain is currently out of order. See above to fix. -- https://mail.python.org/mailman/listinfo/python-list
Re: Screwing Up looping in Generator
For completeness I was close this is the working code. def get_list_of_names(generator_arg): name_set = set() for name in generator_arg: base = os.path.basename(name.name) filename = os.path.splitext(base)[0] name_set.add(filename) return name_set def data_attr(roots): """Get the root object and iter items.""" for name in names: directory = "output" write_name = name + ".csv" with open(os.path.join(directory, write_name), 'w', newline='') as csvf: race_writer = csv.writer(csvf, delimiter=',' ) thanks for your time and assistance. It's much appreciated Sayth -- https://mail.python.org/mailman/listinfo/python-list
Re: Choosing a Python IDE. what is your Pythonish recommendation? I do not know what to choose.
On 04.01.2017 07:54, Antonio Caminero Garcia wrote: Unfortunately most of the time I am still using print and input functions. I know that sucks, I did not use the pdb module, I guess that IDE debuggers leverage such module. pdb is actually quite useful. On my Windows PCs I can invoke python on any .py file with the -i command line switch by right clicking in the Explorer and selecting "Debug". Now when the script crashes, I can inspect variables without launching a full-scale IDE or starting the script from the command line. For such quick fixes I have also a context menu entry "Edit" for editing with Pythonwin, which is still quite OK as editor and has no licensing restrictions or installation requirements. This is a nice option when you deploy your installation to many PCs over the network. For the print functions vs. debugger: The most useful application for a debugger like Wing is not for bug-fixing, but to set a break point and then interactively develop on the debugger console and with the IDE editor's autocompletion using introspection on the live objects. This is very helpful for hardware interfacing, network protocols or GUI programs. It really boosted my productivity in a way I could not believe before. This is something most people forget when they evaluate programming languages. It's not the language or syntax that counts, but the overall environment. Probably the only other really interactive language and environment is Forth. If it happens to be Arduino I normally use a sublime plugin called Stino https://github.com/Robot-Will/Stino (1337 people starred that cool number :D) Well, it is CodeWarrior which was quite famous at the time of the 68k Macs. The company was bought by Motorola and the IDE is still around for Freescale/NXP/Qualcomm microcontrollers like the HCS08 8 bit series. Around ten years ago the original CodeWarrior IDE was migrated to something Eclipse based. When I last evaluated HCS08 vs. Arduino, the HCS08 won due to the better debug interface and native USB support. HCS08 is still quite cool, but when it comes to documentation, learning curve, tools etc. the Arduinos win Regards, Dietmar -- https://mail.python.org/mailman/listinfo/python-list
Re: Choosing a Python IDE. what is your Pythonish recommendation? I do not know what to choose.
On 04.01.2017 15:41, William Ray Wing wrote: I use Wing, and I think you will like it. It *is* pythonic, and for what it is worth, offers remote debugging as one of its more recently added features. Obviously, you had no other choice than using Wing ;-) The remote debugging has been around for some years. I have been using it quite often to debug on my Raspberry Pi, Nokia N900 and Jolla Phone, all running some Linux system. It works well. It is or was a bit complicated to set up. I think this has been improved with Wing 6, but I did not need it in the last weeks, so I don't know. Regards, Dietmar -- https://mail.python.org/mailman/listinfo/python-list
Work between multiple processes
Hi everyone, I ran into a case that I need to create a work process of an application (Jython so has to call using java.exe) which will collect the data based on what main process indicates. (1) I tried multiprocessing package, no luck. Java.exe can't be called from Process class? (2) I tried subprocess. subprocess.communicate function will wait for the work process to terminate so to return. either (1) or (2) doesn't work out well. Please suggest. Global system queue? Thanks, Patrick. -- https://mail.python.org/mailman/listinfo/python-list
Re: Choosing a Python IDE. what is your Pythonish recommendation? I do not know what to choose.
On Montag, 2. Januar 2017 03:38:53 Antonio Caminero Garcia wrote: > Hello, I am having a hard time deciding what IDE or IDE-like code editor > should I use. This can be overwhelming. > > So far, I have used Vim, Sublime, Atom, Eclipse with PyDev, Pycharm, > IntelliJ with Python plugin. Well, since nobody mentioned it, yet: eric is doing quite nice here. With on the fly error checking, jedi and qscintilla calltips and autocompletion, git integration (using a plugin), graphical debugger, it's grown to a capable IDE over the years. Given, it's a fully open source, PyQt based project, it also shows the powers of Python3 and PyQt. Pete -- https://mail.python.org/mailman/listinfo/python-list
RE: Clickable hyperlinks
Chris Angelico wrote, on January 04, 2017 4:16 AM
>
> On Wed, Jan 4, 2017 at 10:43 PM, Deborah Swanson
> wrote:
> > I'm quite well aware by now that there is no one-sentence
> answer to my
> > original question, if there's any coherent answer at all.
> Them's the
> > breaks. Live with it or live without it, it doesn't care.
>
> Yeah, there's no simple answer; however, you'll find that
> Python on many platforms is entirely capable of popping a URL
> up in the user's default browser. Check this out:
>
> >>> import antigravity
>
> This uses the 'webbrowser' module, which knows about a number
> of different ways to open a browser, and will attempt them
> all. So if you can figure out the UI part of things, actually
> making the link pop up in a browser isn't too hard; for
> instance, if you're doing OAuth at the command line and need
> the user to go and authenticate, you can simply
> webbrowser.open("http://.../";) and it'll DTRT.
>
Thank you, thank you! Finally, at least one person on this list knows
about something (anything) in the python world that is internet aware.
It's also occurred to me that Beautifulsoup downloads data from a url,
so that code must have access to some kind of an internet engine too.
I googled antigravity and found a number of interesting links.
The History of Python: import antigravity
http://python-history.blogspot.com/2010/06/import-antigravity.html
Among other things, it was added to Python 3 in 2010, so it's been
around a little while. And a comment mentions that "The antigravity
module is also included in Python 2.7."
And a reddit poster tells us that "if you type 'import antigravity' into
a Python command line your default browser opens the XKCD comic 'Python'
in a tab."
https://www.reddit.com/r/ProgrammerHumor/comments/1hvb5n/til_if_you_type
_import_antigravity_into_a_python/
An "import antigravity" video at
https://www.youtube.com/watch?v=_V0V6Rk6Fp4
And its page in the Package Index:
https://pypi.python.org/pypi/antigravity/0.1, with a Page Not Found
Error for the Home Page. So it doesn't look like there's any alternative
but to download it and look at the code.
Yes, I'd gotten as far as figuring out that you don't need a clickable
link. Code that opens a url in a browse would do the job just fine. Or
the webbrowser.open("http://.../";) in a Linux terminal you suggest.
(I just have to get my Linux machine up and running again to try it.)
All in all, given that clickable urls in a console is a non-starter,
this hits the nail on the head. Many thanks again!
Deborah
--
https://mail.python.org/mailman/listinfo/python-list
Re: Choosing a Python IDE. what is your Pythonish recommendation? I do not know what to choose.
> On Jan 4, 2017, at 3:44 PM, Dietmar Schwertberger > wrote: > > On 04.01.2017 15:41, William Ray Wing wrote: >> I use Wing, and I think you will like it. It *is* pythonic, and for what it >> is worth, offers remote debugging as one of its more recently added features. > Obviously, you had no other choice than using Wing ;-) I should have said something. First, and to the best of my knowledge, I have no relationship with the Wing developers other than being a satisfied customer. Second, seven years ago, when I was reading IDE reviews and testing the more highly rated products, Wing just bubbled up to the top of the sieve I was using (features, ease of use, and the way it fit my idea of “natural”, pretty much everyone's standard list). > > The remote debugging has been around for some years. I have been using it > quite often to debug on my Raspberry Pi, Nokia N900 and Jolla Phone, all > running some Linux system. It works well. It is or was a bit complicated to > set up. I think this has been improved with Wing 6, but I did not need it in > the last weeks, so I don't know. They claim it has been, but like you, I haven’t had need to test it on the new release. Thanks, Bill > > Regards, > > Dietmar > -- > https://mail.python.org/mailman/listinfo/python-list -- https://mail.python.org/mailman/listinfo/python-list
Re: Hey, I'm new to python so don't judge.
On 1/3/2017 10:15 PM, Dennis Lee Bieber wrote: And that statement tells us you are trying to run from within some IDE/editor which is trapping Python exceptions and producing a dialog box for them. IDLE does this when one runs code from the editor, because it cannot/should not inject error messages into the editor buffer... AND it replaces the ^ with red highlighting of the code pointed to. No information is lost. Apparently, some beginners do not see the connection between the SyntaxError box and the red highlighting. I think I should add something to the box. Maybe 'The error was detected at the point of the red highlighting.' Instead, save your script (if you haven't yet) as a file (whatever.py). Open a command line interpreter/shell. Navigate (cd ...) to where you saved the file Type "python whatever.py" What a nuisance. Copy and paste the results of the CLI/Shell window. Or one can hit F5 to run the code or Alt-X to just check the syntax. A beginner should do this every few lines, and it should be as easy as possible to check. If one needs to ask about a syntax error, one can copy the code up and including the highlighted part. Example: "When I run this code in IDLE def is_same(target, number: if I get a SyntaxError at 'if'." If the OP had known to do this, the error might have been seen without posting. -- Terry Jan Reedy -- https://mail.python.org/mailman/listinfo/python-list
Re: Clickable hyperlinks
On Thu, Jan 5, 2017 at 9:58 AM, Deborah Swanson
wrote:
> Chris Angelico wrote, on January 04, 2017 4:16 AM
>> This uses the 'webbrowser' module, which knows about a number
>> of different ways to open a browser, and will attempt them
>> all. So if you can figure out the UI part of things, actually
>> making the link pop up in a browser isn't too hard; for
>> instance, if you're doing OAuth at the command line and need
>> the user to go and authenticate, you can simply
>> webbrowser.open("http://.../";) and it'll DTRT.
>>
>
> Thank you, thank you! Finally, at least one person on this list knows
> about something (anything) in the python world that is internet aware.
> It's also occurred to me that Beautifulsoup downloads data from a url,
> so that code must have access to some kind of an internet engine too.
We've been all talking at cross purposes a bit in this thread. Most of
us thought you were talking about the *user interface* of a clickable
link, but if you're talking about the *mechanics* of HTTP downloads,
Python has excellent facilities. I'd recommend checking out the
third-party 'requests' module on PyPI.
> I googled antigravity and found a number of interesting links.
>
> The History of Python: import antigravity
> http://python-history.blogspot.com/2010/06/import-antigravity.html
>
> Among other things, it was added to Python 3 in 2010, so it's been
> around a little while. And a comment mentions that "The antigravity
> module is also included in Python 2.7."
>
> And a reddit poster tells us that "if you type 'import antigravity' into
> a Python command line your default browser opens the XKCD comic 'Python'
> in a tab."
> https://www.reddit.com/r/ProgrammerHumor/comments/1hvb5n/til_if_you_type
> _import_antigravity_into_a_python/
>
> An "import antigravity" video at
> https://www.youtube.com/watch?v=_V0V6Rk6Fp4
Hehe, yeah. It's a big joke that started because XKCD mentioned the
language. But actually, the source code for antigravity.py itself
isn't significant; all it does is call on the webbrowser module:
https://docs.python.org/3/library/webbrowser.html
> Yes, I'd gotten as far as figuring out that you don't need a clickable
> link. Code that opens a url in a browse would do the job just fine. Or
> the webbrowser.open("http://.../";) in a Linux terminal you suggest.
> (I just have to get my Linux machine up and running again to try it.)
>
> All in all, given that clickable urls in a console is a non-starter,
> this hits the nail on the head. Many thanks again!
Cool! Glad I could help out a bit. There are a few different things
you can consider:
1) Open up a browser tab and let the user see the result
2) Make the request programmatically and access the text of the page
for further processing
3) Invoke a hidden web browser, browse to a URL, submit form data,
etc, as a means of testing a web server.
All three are possible. Take your pick!
ChrisA
--
https://mail.python.org/mailman/listinfo/python-list
Re: Clickable hyperlinks
On 1/4/2017 4:32 AM, Deborah Swanson wrote:
My original question was whether python had anything to provide this
functionality, and the answer appears to be a resounding NO!!!
I would say 'Yes, but with user effort'.
To have a string interpreted as a clickable link, you send the string to
software capable of creating a clickable link, plus the information
'this is a clickable link'*. There are two ways to tag a string as a
link. One is to use markup around the url in the string itself.
'' and html are example. Python provides multiple to make this
easy. The other is to tag the string with a separate argument. Python
provides tkinter, which wraps tk Text widgets, which have a powerful tag
system. One can define a Link tag that will a) cause text to be
displayed, for instance, blue and underlined and b) cause clicks on the
text to generate a web request. One could then use
mytext.insert('insert', 'http://www.example.com', Link)
Browser must do something similar when they encounter when they
encounter html link tags.
* If the software directly recognizes a bare url such as
'http://www.example.com' as a link, without further indication, then it
should have a way to disable conversion to a clickable link.
--
Terry Jan Reedy
--
https://mail.python.org/mailman/listinfo/python-list
MySQL schema sync or diff
Hello, I have a MySQL database that is not managed (yet) and I would like to get an output or diff against my new model file. I'm using flask-sqlalchemy. Are there any modules that would help me discover the differences so that I can script a migration to begin using flask-migrate? Thanks! -- https://mail.python.org/mailman/listinfo/python-list
RE: Clickable hyperlinks
D'Arcy Cain wrote, on Wednesday, January 04, 2017 5:03 AM
>
> Deborah - please trim your quoted text.
Yes, I will. Some lists want to have it all to review in one message,
some want it trimmed to just the lines you are responding to. I was just
waiting to see what this list wants.
> On 2017-01-04 04:32 AM, Deborah Swanson wrote:
> > But we aren't trying to print strings here, the point is to produce
> > clickable links. I didn't enclose them with quotes because I didn't
> > see any point in printing plain text when I wanted
> clickable links. I
>
> I'm not sure what your links are composed of but mine all look like
> sequences of characters or "strings." It sounds like you are
> trying to
> make URL a first class type like strings. integers, floats, etc. I
> can't think of any language that treats URLs as first class objects.
> Even HTML needs quotes:
>
>http://...";>Go here
It seemed reasonable that you might be able to print urls, which is why
I tried the experiment with all of Steven's suggested formats. But I was
highly skeptical that any would work without some kind of modifiers to a
bare print statement.
> > actually didn't understand why you thought I should print
> them, but it
>
> You want to output them to something. That often involves
> printing them
> to a particular handler.
Yes, that's one of the things I would expect if we could print them.
> > never would have occurred to me that you wanted me to print out a
> > bunch of silly plain text strings, apparently just for the
> heck of it.
>
> Is that really what you got from his message?
Please forgive me, and I hope Steven forgives me too, but I was sick to
death of all the beating on a dead horse (using Python to make clickable
links in a console, any console). I'd taken heart when he first
suggested his print experiment, because it was a plausible approach. But
I lost my temper when he upbraided me in this message for failing to
enclose my strings in quotes, in a most patronizing kind of way, when
printing out plain text was absolutely nowhere on the progress toward a
solution scale. I've been quite impressed with Steven's knowledge and
talent, and after fending off the throng of unseeing naysayers all
afternoon, it was just a little too much. I really should have closed my
email reader hours before I read and replied to this message. Shoulda,
coulda, woulda.
> I can assure you that FF prints the string at some point. It
> may wrap
> it in HTML tags first but printing is what it does. Also,
> the URLs are
> stored as strings. SQLite has no URL type. If it did then it would
> still store it as a string somewhere. PostGreSQL would let
> you create a
> URL type if you wanted but you would still need to wrap it in quotes
> (single in this case) when you created the entry.
I have no doubt that some variant of printing is involved. Transporting
urls to the internet is an output process. FF's sqlite implementation
does store urls as a text field in at least 2 tables. I would be
interested in how FF takes those text urls and opens web pages with
them, although I've learned and figured out just today some ways that
Python can also do it. Turns out clickable links were a red herring.
If Steven's original suggestion included anything but a bare print
statement, like the use of a special specifier or linking the print
statement to some module, the use of quoted strings would have at least
been worthy of consideration. But we all know what
print("http://www.wherever.com";) would print, and it would be utterly
worthless for the purpose at hand. Trying the print statement without
the quotes was a least a possibility, if there was any awareness in the
print code of urls and what to do with them. That was the whole point of
this fishing expedition, as I saw it. To see if there was any
undocumented or narrowly known-of features in the print code.
> In all the messages in this thread I still don't understand what this
> "teensy advantage" is supposed to be. Do you want to be able
> to do this:
>
>make_web_link(http://...)
>
> instead of:
>
>make_web_link("http://...";)
>
> --
> D'Arcy J.M. Cain
> System Administrator, Vex.Net
> http://www.Vex.Net/ IM:[email protected]
> VoIP: sip:[email protected]
You probably didn't see my oneliner on the "why do it" part in the swarm
of messages on this thread yesterday. In it I mentioned that the use
would be to open urls in the data I'm working with while I'm debugging
the code that uses them. I want to see what pages they open, without
having to leave my IDE. (Obviously I'd have to open another .py file,
but that would be easier and quicker than the alternatives.) I never
intended my original question to be any more than a frivolous toss out
into the sea, to see if anyone knew an answer. I was flat out astonished
when it blew up into the mini-monster that it did.
Is make_web_link("http://...";) valid python code? That's exactly the
kind of answer I was l
Re: Clickable hyperlinks
On 01/04/2017 03:58 PM, Deborah Swanson wrote:
> Thank you, thank you! Finally, at least one person on this list knows
> about something (anything) in the python world that is internet aware.
> It's also occurred to me that Beautifulsoup downloads data from a url,
> so that code must have access to some kind of an internet engine too.
Except that you never mentioned anything about this in your posts
before. It seemed to me you were asking about printing out clickable
hyperlinks with python. Calling the OS to launch a browser to view a
url is a different beast which is why no one mentioned it before.
If you don't tell us what you're actually trying to do (your end goal),
things are more frustrating for everyone. If you had said early on you
just want to be able to send the user to a particular url in a web
browser, what Chris suggested would have been said a long time ago,
rather than focusing on console output which is what you were asking
about and focusing attention on.
Just so you know, BeautifulSoup does not do any internet access itself;
it's only an HTML parser. You have to fetch web pages using something
like python's urllib and then feed the data to BeautifulSoup. urllib is
not a web browser though. It can pretend to be a browser as far as the
server is concerned but it knows nothing about javascript or rendering.
It just retrieves bytes which you can then feed to BeautifulSoup or some
other parser.
> Yes, I'd gotten as far as figuring out that you don't need a clickable
> link. Code that opens a url in a browse would do the job just fine.
Good! I just wish you would have mentioned this much earlier as your end
goal.
> Or the webbrowser.open("http://.../";) in a Linux terminal you suggest.
> (I just have to get my Linux machine up and running again to try it.)
The webbrowser module does not require console or terminal output. It
will work on Windows or Linux if I'm not mistaken. It asks the OS to
launch the default browser and load the indicated url.
> All in all, given that clickable urls in a console is a non-starter,
> this hits the nail on the head. Many thanks again!
--
https://mail.python.org/mailman/listinfo/python-list
Re: Hey, I'm new to python so don't judge.
On Thursday 05 January 2017 10:21, Terry Reedy wrote: > On 1/3/2017 10:15 PM, Dennis Lee Bieber wrote: > >> And that statement tells us you are trying to run from within some >> IDE/editor which is trapping Python exceptions and producing a dialog >> box for them. > > IDLE does this when one runs code from the editor, because it > cannot/should not inject error messages into the editor buffer... > AND it replaces the ^ with red highlighting of the code pointed to. No > information is lost. Apparently, some beginners do not see the > connection between the SyntaxError box and the red highlighting. Some people may not even be able to distinguish red from other colours. Those with red-green colourblindness will probably see the red as a sort of muddy brown that hardly stands out as different from usual black text. http://wearecolorblind.com/ One should never use colour alone as the only indicator of status. http://stackoverflow.com/questions/1498669/gui-design-for-color-blindness http://davemeeker.com/color-blind-considerations-for-ui-design/ > I > think I should add something to the box. Maybe 'The error was detected > at the point of the red highlighting.' I just tested the REPL in idle for 2.7.4, and I get this: >>> print Hello World SyntaxError: invalid syntax where "print" is green text on a white background, and "World" is black text on a red background. That may be unfriendly to the colourblind, and makes coping and pasting the error less helpful. I suggest: - check the colours in a colourblindness simulator, and pay attention to the contrast; is the text still clear? - include the ^ caret as the primary status indicator, delegating colour to secondary; this makes errors in IDLE a little more like the same experience in the standard REPL. If I open a Python file containing: print Hello World and choose "Check Module", IDLE highlights the word "World" in red and displays a dialog showing: There's an error in your program: invalid syntax Suggestion: Change the dialog box to display a read-only text field showing the traceback: File "idletest.py", line 1 print Hello World ^ SyntaxError: invalid syntax and add a button "Copy traceback" to allow the user to copy the text of the traceback and paste it into an email. (Strictly speaking, the Copy button is redundant if the user can select the text in the field, but beginners may not realise the text can be selected.) >> Instead, save your script (if you haven't yet) as a file >> (whatever.py). >> >> Open a command line interpreter/shell. >> >> Navigate (cd ...) to where you saved the file >> >> Type "python whatever.py" > > What a nuisance. *shrug* If you're a Linux user, chances are you already have a shell open and ready to go. And with tab completion, you don't have to type as much as you might think. It just becomes second nature after a while. I type something like "pypathwhat" and the shell will autocomplete directory and filenames. Anyway, this isn't an argument over which is better, IDLE or the system terminal. They both have their advantages and disadvantages, and in practice the real answer to "which is better?" is always "whichever one you are used to". -- Steven "Ever since I learned about confirmation bias, I've been seeing it everywhere." - Jon Ronson -- https://mail.python.org/mailman/listinfo/python-list
Re: Clickable hyperlinks
On 2017-01-04 05:58 PM, Deborah Swanson wrote:
the user to go and authenticate, you can simply
webbrowser.open("http://.../";) and it'll DTRT.
Thank you, thank you! Finally, at least one person on this list knows
about something (anything) in the python world that is internet aware.
Lots of things in Python are Internet aware. That's not the question
you asked though.
It's also occurred to me that Beautifulsoup downloads data from a url,
so that code must have access to some kind of an internet engine too.
Nope. You have to feed it HTML. You either need to generate that or
capture it from somewhere.
--
D'Arcy J.M. Cain
System Administrator, Vex.Net
http://www.Vex.Net/ IM:[email protected]
VoIP: sip:[email protected]
--
https://mail.python.org/mailman/listinfo/python-list
Re: Clickable hyperlinks
On 2017-01-04 07:07 PM, Deborah Swanson wrote:
D'Arcy Cain wrote, on Wednesday, January 04, 2017 5:03 AM
In all the messages in this thread I still don't understand what this
"teensy advantage" is supposed to be. Do you want to be able
to do this:
make_web_link(http://...)
instead of:
make_web_link("http://...";)
[...]
Is make_web_link("http://...";) valid python code? That's exactly the
It's just a made up name. My point was that the first was syntactically
incorrect and the second, while not a real method, was at least parseable.
I think I saw someone else mention this but it bears repeating. When
you ask a question make sure you are presenting the problem and not your
solution to a secret problem. Always tell us the actual problem you are
trying to solve. You will get much better answers.
Think of it this way. You drop a ring down a drain. You can ask two
questions, "How do I remove a drain trap?" or "How do I recover a ring
that I dropped down the drain?" If you ask the first question you will
get lots of advice on tools and buckets, etc. People will assume that
the drain is blocked. Ask the second question and someone might mention
a magnet and a piece of string.
--
D'Arcy J.M. Cain
System Administrator, Vex.Net
http://www.Vex.Net/ IM:[email protected]
VoIP: sip:[email protected]
--
https://mail.python.org/mailman/listinfo/python-list
Re: Clickable hyperlinks
This thread does lead to the question: Is the Url type in python less first-class than it could be? In scheme I could point to something like this https://docs.racket-lang.org/net/url.html Is there something equivalent in python? -- https://mail.python.org/mailman/listinfo/python-list
Is there a good process or library for validating changes to XML format?
Afternoon Is there a good library or way I could use to check that the author of the XML doc I am using doesn't make small changes to structure over releases? Not fully over this with XML but thought that XSD may be what I need, if I search "python XSD" I get a main result for PyXB and generateDS (https://pythonhosted.org/generateDS/). Both seem to be libraries for generating bindings to structures for parsing so maybe I am searching the wrong thing. What is the right thing to search? Cheers Sayth -- https://mail.python.org/mailman/listinfo/python-list
Re: Clickable hyperlinks
On Thu, Jan 5, 2017 at 2:24 PM, D'Arcy Cain wrote: > Think of it this way. You drop a ring down a drain. You can ask two > questions, "How do I remove a drain trap?" or "How do I recover a ring that > I dropped down the drain?" If you ask the first question you will get lots > of advice on tools and buckets, etc. People will assume that the drain is > blocked. Ask the second question and someone might mention a magnet and a > piece of string. ... and then you follow up with "it's a gold ring, magnet won't touch it", and we'll go off on a tangent about whether the ring is sufficiently plain that it might be the One Ring, and shouldn't you destroy it instead of retrieving it because that's what we do here :D ChrisA -- https://mail.python.org/mailman/listinfo/python-list
RE: Clickable hyperlinks
Chris Angelico wrote, on January 04, 2017 4:16 AM > > Yeah, there's no simple answer; however, you'll find that > Python on many platforms is entirely capable of popping a URL > up in the user's default browser. Check this out: > > >>> import antigravity I downloaded the code from the Package Index, but there really wasn't much in it. This is the entire .py file: STRIP_URL = "http://xkcd.com/353/"; def start(): return STRIP_URL And setup.py is equally disappointing: from distutils.core import setup setup( name='antigravity', version='0.1', description='A really simple module that allow everyone to do "import antigravity"', author='Fabien Schwob', author_email='[email protected]', url='http://fabien.schwob.org/antigravity/', packages=['antigravity'], ) > This uses the 'webbrowser' module, which knows about a number > of different ways to open a browser, and will attempt them > all. So if you can figure out the UI part of things, actually > making the link pop up in a browser isn't too hard; for > instance, if you're doing OAuth at the command line and need > the user to go and authenticate, you can simply > webbrowser.open("http://.../";) and it'll DTRT. > > ChrisA All the action of antigravity must be done by the import statement. When import opens a module that immediately returns a url, it must have a mechanism to open it in a browser. It would be very easy to do the same thing with my own .py and import it into another .py. Or, take a look at import's code and figure out how it opens a url in a browser. I imagine it's the 'webbrowser' module you mention. If it tries several methods, just pick one that will work for you. Or, take a look at this Index of Packages Matching 'webbrowser' (~50 packages) https://pypi.python.org/pypi?%3Aaction=search&term=webbrowser&submit=sea rch D'Arcy was right, there's lots in python that's internet aware, though that wasn't the question I knew to ask. -- https://mail.python.org/mailman/listinfo/python-list
Re: Clickable hyperlinks
On Thu, Jan 5, 2017 at 3:19 PM, Deborah Swanson wrote: > I downloaded the code from the Package Index, but there really wasn't > much in it. This is the entire .py file: Ehh, wrong file. Try the one in the standard library: https://github.com/python/cpython/blob/master/Lib/antigravity.py https://github.com/python/cpython/blob/master/Lib/webbrowser.py Or you can look in your installed Python - "import webbrowser; print(webbrowser.__file__)" will tell you where. ChrisA -- https://mail.python.org/mailman/listinfo/python-list
Re: Clickable hyperlinks
On 01/04/2017 09:19 PM, Deborah Swanson wrote: > Or, take a look at import's code and figure out how it opens a url in a > browser. I imagine it's the 'webbrowser' module you mention. If it tries > several methods, just pick one that will work for you. webbrowser is part of the python standard library: https://docs.python.org/3/library/webbrowser.html It uses whatever method is appropriate for the platform for opening a url in the user's default browser. > Or, take a look at this Index of Packages Matching 'webbrowser' (~50 > packages) > https://pypi.python.org/pypi?%3Aaction=search&term=webbrowser&submit=sea > rch There may be modules in there that will be useful, but the first port of call should always be the python standard library. > D'Arcy was right, there's lots in python that's internet aware, though > that wasn't the question I knew to ask. That's why it's always good to state your end goal when asking about things. -- https://mail.python.org/mailman/listinfo/python-list
RE: Clickable hyperlinks
Chris Angelico wrote, on January 04, 2017 3:49 PM
>
> On Thu, Jan 5, 2017 at 9:58 AM, Deborah Swanson
> wrote:
> >
> > Thank you, thank you! Finally, at least one person on this list
knows
> > about something (anything) in the python world that is internet
aware.
>
> We've been all talking at cross purposes a bit in this
> thread. Most of us thought you were talking about the *user
> interface* of a clickable link, but if you're talking about
> the *mechanics* of HTTP downloads, Python has excellent
> facilities. I'd recommend checking out the third-party
> 'requests' module on PyPI.
My original question was in fact whether there was a way to make
clickable hyperlinks in a console. I was persuaded after about 10
replies that the answer was no, and I tried with little success to
change the question to one of directly opening a url in a browser from
Python. (In hindsight, maybe I should have started a new thread.) Turns
out this version of the question does have good answers, but the revised
question got totally drowned out in the scramble to show that clickable
links in a console are a no-go. I'm not surprised that you didn't see
the shift in what I was looking for.
>
> Hehe, yeah. It's a big joke that started because XKCD
> mentioned the language. But actually, the source code for
> antigravity.py itself isn't significant; all it does is call
> on the webbrowser module:
>
https://docs.python.org/3/library/webbrowser.html
I saw how insignificant antigravity's code is when I downloaded it from
the Package Index, and I copied the current version into another message
of yours that I replied to before this one. The original antigravity may
have used webbrowser, but now it just returns a url and hands it off to
import to open it. Maybe the author didn't know import had that
capability until after antigravity had been in the wild awhile.
Regardless, antigravity does point the way to pythonic web access.
> Yes, I'd gotten as far as figuring out that you don't need a clickable
> link. Code that opens a url in a browser would do the job just fine.
Or
> the webbrowser.open("http://.../";) in a Linux terminal you
> suggest. (I just have to get my Linux machine up and running again to
> try it.)
>
> All in all, given that clickable urls in a console is a non-starter,
> this hits the nail on the head. Many thanks again!
Cool! Glad I could help out a bit. There are a few different things you
can consider:
1) Open up a browser tab and let the user see the result
2) Make the request programmatically and access the text of the page for
further processing
3) Invoke a hidden web browser, browse to a URL, submit form data, etc,
as a means of testing a web server.
All three are possible. Take your pick!
ChrisA
I have a fourth option. I use Firefox with profiles and I could make one
specifically for this task, and have the code open the page in that
profile. This would give it it's own window, history, bookmarks, and
sqlite database, which could be handy if a particular url continues to
be a problem, or I want to track it for some reason. In this project I
usually would want to look at the photos, so a text download wouldn't be
that helpful. But it could be in some other project, and I expect to be
doing quite a bit of web work down the road.
--
https://mail.python.org/mailman/listinfo/python-list
RE: Clickable hyperlinks
Chris Angelico wrote, on January 04, 2017 8:27 PM > > On Thu, Jan 5, 2017 at 3:19 PM, Deborah Swanson > wrote: > > I downloaded the code from the Package Index, but there really wasn't > > much in it. This is the entire .py file: > > Ehh, wrong file. Try the one in the standard library: > https://github.com/python/cpython/blob/master/Lib/antigravity.py https://github.com/python/cpython/blob/master/Lib/webbrowser.py >Or you can look in your installed Python - "import webbrowser; print>(webbrowser.__file__)" will tell you where. > >ChrisA Great! I will check it out. Thanks again! -- https://mail.python.org/mailman/listinfo/python-list
Re: Hey, I'm new to python so don't judge.
On 1/4/2017 9:51 PM, Steven D'Aprano wrote: On Thursday 05 January 2017 10:21, Terry Reedy wrote: IDLE does this when one runs code from the editor, because it cannot/should not inject error messages into the editor buffer... AND it replaces the ^ with red highlighting of the code pointed to. No information is lost. Apparently, some beginners do not see the connection between the SyntaxError box and the red highlighting. Some people may not even be able to distinguish red from other colours. Those with red-green colourblindness will probably see the red as a sort of muddy brown that hardly stands out as different from usual black text. http://wearecolorblind.com/ One should never use colour alone as the only indicator of status. http://stackoverflow.com/questions/1498669/gui-design-for-color-blindness http://davemeeker.com/color-blind-considerations-for-ui-design/ I have described what I inherited. After I wrote this, it occurred to me that perhaps the error color should be flashing, a bell rung, and maybe even the line and column numbers included in the box. I think I should add something to the box. Maybe 'The error was detected at the point of the red highlighting.' I just tested the REPL in idle for 2.7.4, and I get this: print Hello World SyntaxError: invalid syntax where "print" is green text on a white background, and "World" is black text on a red background. That may be unfriendly to the colourblind, and makes coping and pasting the error less helpful. I suggest: - check the colours in a colourblindness simulator, and pay attention to the contrast; is the text still clear? User can configure most of the syntax colors. I am not sure ir the error 'red' is one of them or not. #Suggestion 1 - include the ^ caret as the primary status indicator, delegating colour to secondary; this makes errors in IDLE a little more like the same experience in the standard REPL. Indeed, why not both in the Shell? IDLE must currently be deleting the caret line. If I open a Python file containing: print Hello World and choose "Check Module", IDLE highlights the word "World" in red and displays a dialog showing: There's an error in your program: invalid syntax #Suggestion 2 Change the dialog box to display a read-only text field showing the traceback: File "idletest.py", line 1 print Hello World ^ SyntaxError: invalid syntax #Suggestion 3 and add a button "Copy traceback" to allow the user to copy the text of the traceback and paste it into an email. (Strictly speaking, the Copy button is redundant if the user can select the text in the field, but beginners may not realise the text can be selected.) Thank you for the suggestions. I will keep a copy of this. -- Terry Jan Reedy -- https://mail.python.org/mailman/listinfo/python-list
RE: Clickable hyperlinks
Terry Reedy wrote, on January 04, 2017 3:58 PM
>
> On 1/4/2017 4:32 AM, Deborah Swanson wrote:
>
> > My original question was whether python had anything to provide this
> > functionality, and the answer appears to be a resounding NO!!!
>
> I would say 'Yes, but with user effort'.
>
> To have a string interpreted as a clickable link, you send the string
to
> software capable of creating a clickable link, plus the information
> 'this is a clickable link'*. There are two ways to tag a string as a
> link. One is to use markup around the url in the string itself.
> '' and html are example. Python provides multiple to make this
> easy. The other is to tag the string with a separate argument. Python
> provides tkinter, which wraps tk Text widgets, which have a powerful
tag
> system. One can define a Link tag that will a) cause text to be
> displayed, for instance, blue and underlined and b) cause clicks on
the
> text to generate a web request. One could then use
>mytext.insert('insert', 'http://www.example.com', Link)
> Browser must do something similar when they encounter when they
> encounter html link tags.
I've actually moved on from my original question to one of opening a url
in a browser with python, which seems to be a much more easily achieved
goal.
But someone else mentioned tkinter, and I looked at it while ago but
haven't used it for anything. That really could be the way to go if you
want to make clickable links, although you still need some kind of
internet engine to open the url in a browser. PyCharm has clickable
local links in its console output, but they're not internet enabled,
they just jump to the relevant line of code.
You say, "There are two ways to tag a string as a link. One is to use
markup around the url in the string itself. '' and html are
examples. Python provides multiple ways to make this easy."
Can you tell me where I'd begin to look for these? Are they in the core
language, or in packages?
> * If the software directly recognizes a bare url such as
> 'http://www.example.com' as a link, without further
> indication, then it
> should have a way to disable conversion to a clickable link.
One would think so. Thanks for all your info!
>
> --
> Terry Jan Reedy
--
https://mail.python.org/mailman/listinfo/python-list
Re: Clickable hyperlinks
On Thursday 05 January 2017 14:22, Rustom Mody wrote:
> This thread does lead to the question:
> Is the Url type in python less first-class than it could be?
>
> In scheme I could point to something like this
> https://docs.racket-lang.org/net/url.html
Those docs say:
"To access the text of a document from the web, first obtain its URL
AS A STRING..." [emphasis added]
which means that URLs are not a first-class data type in Racket at all. URLs in
Racket are just strings, exactly the same as in Python.
There is a url struct:
https://docs.racket-lang.org/net/url.html#%28def._%28%28lib._net%2Furl-
structs..rkt%29._url%29%29
but there no first-class syntactic support for them, as ints and lists have in
Python:
123 # rather than int("123")
[1, 2] # rather than list(1, 2)
> Is there something equivalent in python?
Just like Racket, URLs in Python are not first-class. They start as a string,
and then you parse them into a tuple:
https://docs.python.org/3/library/urllib.parse.html
https://docs.python.org/2/library/urlparse.html
--
Steven
"Ever since I learned about confirmation bias, I've been seeing
it everywhere." - Jon Ronson
--
https://mail.python.org/mailman/listinfo/python-list
Re: Clickable hyperlinks
On 1/5/2017 12:11 AM, Deborah Swanson wrote:
Terry Reedy wrote, on January 04, 2017 3:58 PM
To have a string interpreted as a clickable link, you send the string
to
software capable of creating a clickable link, plus the information
'this is a clickable link'*. There are two ways to tag a string as a
link. One is to use markup around the url in the string itself.
'' and html are example. Python provides multiple to make this
easy. The other is to tag the string with a separate argument. Python
provides tkinter, which wraps tk Text widgets, which have a powerful
tag
system. One can define a Link tag that will a) cause text to be
displayed, for instance, blue and underlined and b) cause clicks on
the
text to generate a web request. One could then use
mytext.insert('insert', 'http://www.example.com', Link)
Browser must do something similar when they encounter when they
encounter html link tags.
I've actually moved on from my original question to one of opening a url
in a browser with python, which seems to be a much more easily achieved
goal.
But someone else mentioned tkinter, and I looked at it while ago but
haven't used it for anything. That really could be the way to go if you
want to make clickable links, although you still need some kind of
internet engine to open the url in a browser.
IDLE allows a user to add help menu entries that, when clicked on, open
either a local file or an internet url. For instance, adding the pair
'Pillow' and "https://pillow.readthedocs.io/en/latest/"; in the Settings
dialog adda "Pillow" to the help menu (after the standard stuff).
Clicking on Help => Pillow opens
"https://pillow.readthedocs.io/en/latest/"; in the default browswer.
IDLE just used the webbrowser module to do this. No use re-inventing
the wheel. If instead "Pillow" were a link in text, the click handler
should do something similar.
You say, "There are two ways to tag a string as a link. One is to use
markup around the url in the string itself. '' and html are
examples. Python provides multiple ways to make this easy."
Can you tell me where I'd begin to look for these? Are they in the core
language, or in packages?
I was referring to using either % or .format string formatting. Both
are in the core and described somewhere in the Library manual. '%'
should be in the Symbols page of the Index and 'format' on the 'F' page.
--
Terry Jan Reedy
--
https://mail.python.org/mailman/listinfo/python-list
