Re: python multiprocessing
Xristos Xristoou writes: > I have three functions in the python that each one puts an image (image path) > as input and makes a simple image processing and creates a new image (image > path) as output. In order to make effective use of multiprocessing, you need to split your complete task into (mostly) independent subtasks and let them be processed by subprocesses. For this to be effective, the subtasks must need significant processing. If dependencies remain, the processes must communicate which makes things more complicated and less efficient. I agree with Stefan Ram: if you have essentially a single image which gets processed in order by different alorithms, then you have a sequential process which can not profit from multiprocessing. However, if you have a set of input images, then you can process each image in a separate process -- and potentially gain significantly in speed. -- https://mail.python.org/mailman/listinfo/python-list
Re: The "loop and a half"
On 2017-10-09 04:35, Mikhail V wrote: > Just for people like me who know nothing about networking, > can you popularly explain the : > >> Have you ever worked on a slow remote session where a GUI is >> completely impracticable (or maybe even unavailable), and redrawing >> the screen is too expensive to do all the time? > > So where does the redrawing happen? The machine youre sitting on (let's > call it 'A') and send remote commands or retrieving text files? Or the > redrawing must be synced on both A and > the remote machine? If so, then why so? Because you want to see what you are typing. Imagine you are logged into a server on the other side of the world. You want to edit a file on that machine (for example a configuration file for the web server). You invoke the editor on that server. Now everything the editor wants to display must be sent to your machine so that it can display it on your screen, and everything you do (hit a key, move the mouse) must be sent to the remote machine so that the editor can obey your commands. It is extremely irritating if there is a noticable delay between action and response, so the data must be transferred in both directions quickly. > How does the bandwidth implies that you must edit stuff in the console on > A? I'm not sure what you mean be "in the console on A". What you usually do is invoke an SSH client on A ("ssh" on Linux, "putty" on Windows) to connect to the server and then invoke the editor there. > And not in a nice editor with normal fonts? > Am i missing something or your 'A' machine cannot use graphics? Your A machine can use graphics. The server may not be able to (it's a server, why would anyone install a GUI on it?), and even if it could, streaming the screen contents of a rich GUI around the world may be not be possible for bandwidth or delay reasons. What you could do is copy the file from the server to your computer, edit it there and then copy it back. But that's two extra steps and it may not even be possible in some cases (maybe you can't reach the server directly, but only over one or more bastion hosts). > Even on 386 computers there was graphics and keybord&mouse input. That > is definitely what I would want for editing files. Yes I've tried line > by line eding back in DOS times and that really sucks. There is a wide gap between line editing and graphical editors. Text-terminal oriented editors (like vi, emacs, nano in the Unix world or KEdit or e4 in the MS-DOS world) are not line based. They use the full screen, and they can often also use the mouse. They are just restricted to a rectangular grid of characters for display purposes. Not much of a restriction if you want to edit only text. hp -- _ | Peter J. Holzer| Fluch der elektronischen Textverarbeitung: |_|_) || Man feilt solange an seinen Text um, bis | | | h...@hjp.at | die Satzbestandteile des Satzes nicht mehr __/ | http://www.hjp.at/ | zusammenpaßt. -- Ralph Babel -- https://mail.python.org/mailman/listinfo/python-list
Re: on = style
On Mon, 9 Oct 2017 05:56 pm, Stefan Ram wrote: > Abdur-Rahmaan Janhangeer writes: >>hi just a quick question, why is > > When you post a new question, you should start a new thread. > Your post already has many other posts in the References header. > >>my_pens = 4 >>my_pencils = 5 >>is preffered to >>my_pens= 4 >>my_pencils = 5 > > "preferred" > > The rationale is not clear to me. Could be: > > abc = 2 > def = 3 > ghi = 4 > jkl = 5 > mno = 6 > pqr = 7 > stu = 8 > vwx = 9 > abcdefghijklmnopqrstuvwxyzabcdefghij = 0 And then when you add another line: abcdefghijklmnopqrstuvwxyzabcdefghijαβγδεζηθικλμ = 1 you have to waste time lining everything up again: abcdefghijklmnopqrstuvwxyzabcdefghij[αβγδεζηθικλμ] = 1 abc = 2 def = 3 ghi = 4 jkl = 5 mno = 6 pqr = 7 stu = 8 vwx = 9 abcdefghijklmnopqrstuvwxyzabcdefghij = 0 And then later you decide that's a damn ridiculously long line, so you split it over two: abcdefghijklmnopqrstuvwxyzabcdefghij[ αβγδεζηθικλμ] = 1 abc = 2 def = 3 ghi = 4 jkl = 5 mno = 6 pqr = 7 stu = 8 vwx = 9 abcdefghijklmnopqrstuvwxyzabcdefghij = 0 so now you waste MORE time aligning things: abcdefghijklmnopqrstuvwxyzabcdefghij[ αβγδεζηθικλμ] = 1 abc = 2 def = 3 ghi = 4 jkl = 5 mno = 6 pqr = 7 stu = 8 vwx = 9 abcdefghijklmnopqrstuvwxyzabcdefghij = 0 and so it continues. Not only are wasting time, but you make the version control diffs less useful. And the end result is, it becomes much easier to misread one of the lines and accidentally read "mno = 7" instead of 6 and get yourself confused. Assignment values should be close to their variable, not waay over on the far side of the line. > The distance between »jkl« and »5« might make it more > difficult to read which value belongs to which name. There is no "might", it definitely makes reading harder. > Also, sometimes people like to use automated formatting > tools, and they will usually remove such formatting anyway. > > And possibly some people think that it must take time > of the programmer to create and maintain such an alignment, > time in which he is not programming "productively". There's no question about that. I've done it myself, spent five minutes carefully lining up (for example) a dict and arranging things Just Perfectly: mydict = dict(a = 1234, b = 123, c = 123, de = 12, fgh = 1, ij = 12345, klm = 123456789,n = 12345678901, opq = 1, ) and then half an hour later, decide that, no, it is better to sort the items in rows, not columns, so then I spend another ten minutes re-arranging my Perfectly Laid Out dict: mydict = dict(a = 1234, de = 12, klm = 123456789, b = 123, fgh = 1, n = 12345678901, c = 123, ij = 12345, opq = 1, } and then the next day I decide that, no, it was better the first way, so I spend another ten minutes re-aligning the rows and columns. And *then* I decide that some of the keys are badly named, and I need to change them, and that requires another re-alignment. And then I decide that I need another key, so its no longer a perfect 3x3 square. Should I re-arrange it to a 5x2 or 2x5 rectangle? Obviously I must try both. (If you think I am exaggerating or making this up, I'm not.) Eventually, after spending multiple hours (spread over a couple of days) dicking around, I finally cannot avoid the truth any more, and have to admit to myself that I'm just dicking around and this isn't productive work, it's busy-work to make me look busy while actually avoi
The "loop and a half"
bartc wrote: >> Your job is to port an editor that people have been using for 30 years to >> Linux. The first thing you do is to change all the commands and shortcuts to >> match what is typical on Linux? So that no-one who was familiar with it as >> it was can actually use it? Chris Angelico wrote: > Is it graphical? Does it use any well-known toolkit? If so, then yeah, > the first thing - and the automatic thing - is that it will respond to > the host platform's keys and so on. In case of a toolkit probably, but generally there is no such thing as "host platform's keys" in context of a desktop application. There are keys which the application defines. OS is used only to run the application, (some system keys, e.g. Alt-Tab, Ctrl-Alt-del, are of course better left alone). The first thing a developer should provide - the keys and mouse input should be *customizable* by the user. It is so by most serious application I have ever used. (I don't know though if it is so in Bart's application) Anything that can not - is for me 'below the bar' usability straightaway. (With the exception when the defaults are so good that there is no much need to redefine them, or it is a very simple app with only few input commands) Some frameworks do not provide such customization and that is simply bad design. The second thing - the default keys should be optimized for the input efficiency and ergonomics. Other issues, e.g. whether the keys are same as in some other app or not, becomes irrelevant if the app fulfils the first two criteria (see above). If not, I would consider looking for an alternative app with customizable keys. bartc wrote: >> * Under Windows, if you press Shift while Caps Lock is on, you get lower >> case letters. I've never, ever wanted to do this (probably no one else has). >> My own editor doesn't obey that convention: shift-A will always come out as >> 'A' whatever the caps lock setting. >> >> There are dozens more, yet you are surprised why sometimes I prefer doing >> things my own way? There are good reasons! Chris Angelico wrote: >Yep. Good reasons like that you're a moron. You assume that > since *you* have never needed to produce one lower-case letter > in a block of upper-case, that "probably no one else has", > and then you make it impossible to do that in your editor. > I have wanted to produce a lower-case letter by holding Shift. I think I've never advocated anybody on the list, but here I really don't understand why you are attacking Bart. In this particular Caps lock example - it's pretty clear for me that the input of lowercase letters with Shift is historically there just for the 'symmetry'. Obviously there is zero practical need for that in general case, so "probably no one else need this" is quite appropriate statement. > I have wanted to produce a lower-case letter by holding Shift. Ok, once in my life I have wanted too, just to see what happens, which does not mean that this feature has any value. Mikhail -- https://mail.python.org/mailman/listinfo/python-list
Re: OT again sorry [Re: Interactive scripts (back on topic for once) [was Re: The "loop and a half"]]
On 8 October 2017 at 17:43, Marko Rauhamaa wrote: > It is not at all easy for the Linux user to figure out what > configuration options there are, and which ones are intended for > end-user configuration. More and more, such tuning needs to be > done via systemd unit files (or applicable GUI facilities) and the > classical configuration files are deprecated. For example, how can a > programmer get a core file of a crashing program? Why, you need to use > the systemd-coredump service, of course: One of the things I liked about Debian many years ago when I played with Linux (when the options available were Debian, Red Hat, Slackware and SuSE and that was about it) was that they typically "fixed" the defaults of programs in the build options, so that there were almost no config files in the default install. That made it pretty easy for a user - you just set any extra options you want. With the other distros, they tended to make changes via config files, which was probably more transparent and easier to understand, but meant that a naive user like me couldn't tell what I was "allowed" to change (and by "allowed" I don't mean permission, more "if I change this, will I end up spending days trying to work out what weird interaction with other tools'expectations I just broke"). Sadly, those simpler days are long gone, and nowadays all Linux distros as far as I can see have a mass of predefined config (and the inevitable "config manager" tools to manage them). Not that I can complain about this, as a Windows user, but I do have fond memories of those simpler times :-) Obligatory xkcd: https://xkcd.com/297/ Paul -- https://mail.python.org/mailman/listinfo/python-list
Re: Python GUI application embedding a web browser - Options?
On 9 October 2017 at 04:25, wrote: > Did you find out the answer for that? Nothing much beyond the pointer to PyQt (which basically said "a lot of the info on the web is out of date" so I should check the latest docs). I didn't take it much further, though, as it was a hobby project and the learning curve for PyQt (any GUI framework, really) was a bit high for the amount of spare time I had at the time. Paul -- https://mail.python.org/mailman/listinfo/python-list
Re: The "loop and a half"
On Mon, Oct 9, 2017 at 7:05 PM, Mikhail V wrote: > The first thing a developer should provide - the keys and mouse input > should be > *customizable* by the user. It is so by most serious application I have > ever used. And they most certainly are. Often, in something in the host platform. For instance, Xfce allows me to change the keys used for various purposes, by going into the menu and choosing "Settings" and then "Keyboard". (Or, of course, by editing the config files.) The most obvious and dramatic change you can do is to choose a specific keyboard layout - Qwerty vs Dvorak, US vs German, etc, etc, etc. Do you think that sort of thing should be in the hands of the application, or the platform? (Note that I'm not saying "OS" here. Usually the platform is at a higher level than that; in my case, I would consider Xfce (my desktop manager) to be that.) ChrisA -- https://mail.python.org/mailman/listinfo/python-list
Re: The "loop and a half"
On Mon, 09 Oct 2017 08:00:34 +0200, Lele Gaifax wrote: > Chris Angelico writes: > >>> Or you could use a GUI editor that runs locally and has the capability >>> to edit files remotely over ssh. >> >> That's also a possibility, but I have yet to find one that can SSH to a >> server as a non-root user and then sudo to edit the files. > > If it's just a matter of "finding one", look no further and try out > Emacs's TRAMP :-) > > ciao, lele. or if you want the luxury of a GUI editor simply ssh to the remote machine & run the editor there (using X forwarding to route the display to you local PC) -- The more you sweat in peace, the less you bleed in war. -- https://mail.python.org/mailman/listinfo/python-list
Re: The "loop and a half"
On Mon, Oct 9, 2017 at 8:15 PM, alister via Python-list wrote: > On Mon, 09 Oct 2017 08:00:34 +0200, Lele Gaifax wrote: > >> Chris Angelico writes: >> Or you could use a GUI editor that runs locally and has the capability to edit files remotely over ssh. >>> >>> That's also a possibility, but I have yet to find one that can SSH to a >>> server as a non-root user and then sudo to edit the files. >> >> If it's just a matter of "finding one", look no further and try out >> Emacs's TRAMP :-) >> >> ciao, lele. > > or if you want the luxury of a GUI editor simply ssh to the remote > machine & run the editor there (using X forwarding to route the display > to you local PC) That assumes that you have a GUI editor installed on the server, with all the libraries it requires. Not always the case - especially if you have multiple admins, some who like GNOME and some who like KDE... how many editors and how many subsystems are you going to install? ChrisA -- https://mail.python.org/mailman/listinfo/python-list
Re: The "loop and a half"
alister : > or if you want the luxury of a GUI editor simply ssh to the remote > machine & run the editor there (using X forwarding to route the > display to you local PC) I could be doing it at this very moment. However X11 networking is so clunky that I choose to do it in an SSH text terminal. There is barely any difference in using emacs in text mode than graphically. Marko -- https://mail.python.org/mailman/listinfo/python-list
The "loop and a half"
>>> Have you ever worked on a slow remote session where a GUI is >>> completely impracticable (or maybe even unavailable), and redrawing >>> the screen is too expensive to do all the time? >> >> So where does the redrawing happen? The machine youre sitting on (let's >> call it 'A') and send remote commands or retrieving text files? Or the >> redrawing must be synced on both A and >> the remote machine? If so, then why so? Peter J. Holzer wrote: > Because you want to see what you are typing. Imagine you are logged into > a server on the other side of the world. You want to edit a file on that > machine (for example a configuration file for the web server). You > invoke the editor on that server. I've never done this, but if one told me to edit a file, my first attempt would be like: - get read/write access to the file system - browse it (e.g. some file browser plugin?) - get the file to the local machine - edit locally - write it back to the remote machine >> And not in a nice editor with normal fonts? >> Am i missing something or your 'A' machine cannot use graphics? > ... The server may not be able to > (it's a server, why would anyone install a GUI on it?) If I ever work on it (locally) why would I want a GUI on it? o_O I'm not sure if I'm getting you. You mean probably a server which is never worked on locally? If it has a display and a keyb, and I must do something on it, even seldom, then certainly I want a GUI on it (not just to see a desktop wallpaper ;). > streaming the screen contents of a rich GUI around the world may be not > be possible for bandwidth or delay reasons. Sure, streaming video consumes a lot, but that is what one tries to avoid if under limitations so streaming messages only is faster. Mikhail -- https://mail.python.org/mailman/listinfo/python-list
Re: The "loop and a half"
On Mon, Oct 9, 2017 at 8:44 PM, Mikhail V wrote: >> ... The server may not be able to >> (it's a server, why would anyone install a GUI on it?) > > If I ever work on it (locally) why would I want a GUI on it? (Presuming you mean "wouldn't" here) > o_O I'm not sure if I'm getting you. > You mean probably a server which is never worked on locally? > If it has a display and a keyb, and I must do something on it, even > seldom, then certainly I want a GUI on it (not just to see > a desktop wallpaper ;). If it's a server that also is used directly at its own console, then sure! Have a GUI installed. Right now, for instance, I'm typing this up on my main computer "Sikorsky", who is a full desktop system with four monitors, two webcams, a keyboard, a mouse, and several dozen figurines (they aren't USB-connected or anything, but without Alice, Elsa, Kaylee, and Joy, this just wouldn't be the same). He happens to be a server, providing various facilities to the local network, but he is a client too, so he has a GUI. (Though if I remote in to him from the laptop, I'm *still* going to stick to the terminal, just because it's easier that way.) But there are plenty of servers that don't. You can rent yourself a cheap box on Amazon's EC2 for less than a cent per hour - not much of a box, but enough to do some testing on. It's an easy and cheap way to try things out. But since that box has something like half a gig of RAM, you don't want to waste any of it on a GUI; you want to work with the simplest, lightest-weight user interface you can. That means the "glass teletype" of the terminal; all the fancy features are provided by your client, where you run "ssh some-server" in a local terminal emulator, and the server just has to worry about running the programs themselves. ChrisA -- https://mail.python.org/mailman/listinfo/python-list
Re: The "loop and a half"
On 09/10/2017 06:15, Gregory Ewing wrote: Grant Edwards wrote: Which took it from RSX-11. Or probably more specifically from FILES-11. I woldn't be surprised if the enineers at DEC got it from somewhere else before that. Quite possibly it goes back to the very earliest DEC OS that had files, whatever that was. The reason for it was that the file system only kept track of file sizes in blocks, not bytes, so some way was needed to mark the end of a text file part way through a block. Ctrl-Z was just code 26 or [what I've always called] ETX or end-of-text. I'd used DEC quite a bit (including rsx-11m) but only became aware of ETX when using CP/M. (Where it had a annoying habit, IIRC, of copying files in text mode so that it stopped at the first ETX byte.) And actually, until recently, I added ETX (followed by 0 for good measure) as a sentinel in a function reading a file into a block of memory (now I just use 0 for that purpose). But I don't consider that these internal uses, some of which are archaic, belong in a user interface. [Looking it up now, actual ETX is code 3, or Ctrl-C, and EOT is code 4. So how 26 - apparently code SUB, whatever that means - ended up being used to mark the end of text files, I don't know.] -- bartc -- https://mail.python.org/mailman/listinfo/python-list
Re: The "loop and a half"
On 09/10/2017 05:49, Chris Angelico wrote: Generally, my preferred editor is nano, since it lives within those requirements but still has a decent UI. It's not always available though, and it's useful to know how to manage without it. But even though you won't always be doing this sort of thing, it's definitely something that a *programming language designer* should be aware of. Basic networking is critical to any modern language. That's an odd opinion given that modern languages don't even want to have basic input and output as part of the language; they're offloaded to a library. And in your example, which I don't really understand, it seems more like the headache of the application. (Where a language allows elements of a program to be disseminated across a network, that's rather different, and an advanced feature that only some languages might have. Not all.) -- bartc -- https://mail.python.org/mailman/listinfo/python-list
Re: The "loop and a half"
On Mon, Oct 9, 2017 at 11:43 PM, bartc wrote: > On 09/10/2017 05:49, Chris Angelico wrote: > >> Generally, my preferred editor is nano, since it lives within those >> requirements but still has a decent UI. It's not always available >> though, and it's useful to know how to manage without it. But even >> though you won't always be doing this sort of thing, it's definitely >> something that a *programming language designer* should be aware of. >> Basic networking is critical to any modern language. > > > That's an odd opinion given that modern languages don't even want to have > basic input and output as part of the language; they're offloaded to a > library. And in your example, which I don't really understand, it seems more > like the headache of the application. > > (Where a language allows elements of a program to be disseminated across a > network, that's rather different, and an advanced feature that only some > languages might have. Not all.) The standard libraries of most application languages include both console I/O and networking. ("Application language" excludes such things as JavaScript in a web browser, which for security reasons is not permitted file system access, and has limited console and network features. But Node.js has all of the above.) The distinction between language syntax and the standard library is not overly significant here; things that don't need to be syntax are best implemented with the standard library. We're not talking about third-party libraries here - with a vanilla CPython 3.6 and no external libraries, you can access the console and you can open a socket. (And you get higher-level facilities too - protocols like HTTP, FTP, DNS, and SMTP are handled too.) ChrisA -- https://mail.python.org/mailman/listinfo/python-list
Re: The "loop and a half"
On 2017-10-09, Gregory Ewing wrote: > Grant Edwards wrote: >> Which took it from RSX-11. Or probably more specifically from >> FILES-11. I woldn't be surprised if the enineers at DEC got it from >> somewhere else before that. > > Quite possibly it goes back to the very earliest DEC OS > that had files, whatever that was. > > The reason for it was that the file system only kept track > of file sizes in blocks, not bytes, so some way was needed > to mark the end of a text file part way through a block. A "feature" that CP/M copied almost verbatim. If you looked at the CP/M FCB (file-control-block) structure it looked almost identical to that used by early DEC OSes. DOS then copied CP/M's file i/o scheme even more exactly than CP/M had copied DEC. It was years later than DOS finally copied some Unix features like nested directories, opening files via path strings, etc. -- Grant Edwards grant.b.edwardsYow! Do you think the at "Monkees" should get gas on gmail.comodd or even days? -- https://mail.python.org/mailman/listinfo/python-list
Re: The "loop and a half"
On 2017-10-09, alister via Python-list wrote: > or if you want the luxury of a GUI editor simply ssh to the remote > machine & run the editor there (using X forwarding to route the display > to you local PC) AFAICT, most modern GUI toolkits are no longer usable via X forwarding at sub-gigabit network speeds. The toolkit designers have botched things up so that even the most trivial operation requires hundreds of round-trips between server and client. -- Grant Edwards grant.b.edwardsYow! Did YOU find a at DIGITAL WATCH in YOUR box gmail.comof VELVEETA? -- https://mail.python.org/mailman/listinfo/python-list
Re: The "loop and a half"
Grant Edwards : > On 2017-10-09, alister via Python-list wrote: > >> or if you want the luxury of a GUI editor simply ssh to the remote >> machine & run the editor there (using X forwarding to route the >> display to you local PC) > > AFAICT, most modern GUI toolkits are no longer usable via X forwarding > at sub-gigabit network speeds. The toolkit designers have botched > things up so that even the most trivial operation requires hundreds of > round-trips between server and client. Yep. Funny thing is, xterm runs nicely over a 9,600-baud line, but there's no hope to get Firefox, Evince or the like to run over a 1,500,000 bps connection. Latency is more of an issue than throughput, indicating that those round-trips are sequential. X11 was designed to be pipelined but the toolkits can't pipeline themselves. Marko -- https://mail.python.org/mailman/listinfo/python-list
A programmable python debugger. Set one breakpoint to x-ray everything
peforth If the below explanations would be messy please directly refer to README.md @ https://github.com/hcchengithub/peforth A programmable python debugger. Set one breakpoint to x-ray everything. You guys know how to bebug already. We all do. But when it comes to Machine Learning and Tensorflow or the likes, things are getting annoying if we were still using traditional debuggers. A programmable debugger is what in my mind and probably in yours too. One breakpoint to investigate about everything with procedures that we come out at the point depend on variant needs of emerged ideas good or bad. Debug commands in FORTH syntax So now we need to choose an interactive UI and its syntax that is light weight, reliable and flexible so we won't regret of choosing it someday, has been there for decades so many people don't need to learn about another new language although we are only to use some debug commands, yet easy enough for new users, that's FORTH. Install peforth: pip install peforth Run peforth: Print "Hello World!" Microsoft Windows [Version 10.0.15063] (c) 2017 Microsoft Corporation. All rights reserved. c:\Users\your-working-folder>python -m peforth .' Hello World!!' cr bye Hello World!! c:\Users\your-working-folder> so your peforth has been working fine. To your application, import peforth as usual to bring in the debugger: c:\Users\your-working-folder>python Python 3.6.0 (v3.6.0:41df79263a11, Dec 23 2016, 08:06:12) [MSC v.1900 64 bit (AMD64)] on win32 Type "help", "copyright", "credits" or "license" for more information. >>> import peforth p e f o r t hv1.07 source code http://github.com/hcchengithub/peforth Type 'peforth.ok()' to enter forth interpreter, 'exit' to come back. >>> The greeing message tells us how to enter the FORTH interpreter for your debugging or investigating and how to come back to continue running your code. Let's try to debug a program # 100.py sum = 0 for i in range(100): sum += i print("The sum of 1..100 is ", sum) Run it: c:\Users\your-working-folder>python 100.py The sum of 1..100 is 4950 c:\Users\your-working-folder> The result should be 5050 but it's not! Let's drop a breakpoint to see what's wrong: # 100.py with breakpoing .- Specify an unique command prompt to indicate where | the breakpoint is from if there are many of them import peforth |.- pass locals() at the breakpoint sum = 0|| to our debugger for i in range(100): || .--- use a FORTH constant sum += i || |to represent the locals() peforth.ok('my first breakpoint> ',loc=locals(),cmd="constant locals-after-the-for-loop") print("The sum of 1..100 is ", sum) Run again: c:\Users\your-working-folder>python 100.py p e f o r t hv1.07 source code http://github.com/hcchengithub/peforth Type 'peforth.ok()' to enter forth interpreter, 'exit' to come back. .--- at the breakpoint, type in 'words' |command to see what have we got my first breakpoint> words. It's a long list of 'words' ... snip ... | or available commands. Don't worry, we'll use only some of them. expected_rstack expected_stack test-result [all-pass] *** all-pass [r r] [d d] [p p] WshShell inport OK dir keys --- locals-after-the-for-loop | The last one is what --' we have just created throuth the breakpoint statement , named "locals-after-the-for-loop" Let's see it: print a carriage return at the end ---. print the thing -. | | | my first breakpoint> locals-after-the-for-loop . cr ({'__name__': '__main__', '__doc__': None, '__package__': None, '__loader__': <_frozen_importlib_external.SourceFileLoader object at 0x01DD2D737710>, '__spec__': None, '__annotations__': {}, '__builtins__': , '__file__': '100.py', '__cached__': None, 'peforth': , 'sum': 4950, 'i': 99}, {}, 'my first breakpoint> ') my first breakpoint>| | | | | '--- our command our sum -' |prompt | indicates where the 99 instead of 100 --' breakpoint is from this is the problem !! Now leave the breakpoint and let the program continue: my first breakpoint> exit my first breakpoint> The sum of 1..100 is 4950 c:\Users\your-working-folder> Investigate by running experiments right at a breakpoint When at a breakpoint in Tensorfow tutorials, I always want to make some experiments on those frustrating tf.something(tf.something(...
Re: The "loop and a half"
On Mon, 09 Oct 2017 17:27:27 +0300, Marko Rauhamaa wrote: > Grant Edwards : > >> On 2017-10-09, alister via Python-list wrote: >> >>> or if you want the luxury of a GUI editor simply ssh to the remote >>> machine & run the editor there (using X forwarding to route the >>> display to you local PC) >> >> AFAICT, most modern GUI toolkits are no longer usable via X forwarding >> at sub-gigabit network speeds. The toolkit designers have botched >> things up so that even the most trivial operation requires hundreds of >> round-trips between server and client. > > Yep. > > Funny thing is, xterm runs nicely over a 9,600-baud line, but there's no > hope to get Firefox, Evince or the like to run over a 1,500,000 bps > connection. > > Latency is more of an issue than throughput, indicating that those > round-trips are sequential. X11 was designed to be pipelined but the > toolkits can't pipeline themselves. > > > Marko works fine over my wifi which is considerably less than gigabit speeds then again I only run applications remotely that are sensible to run remotely such as text editors (geany) & file managers (thunar) I cant see any reason why I would want to run a web browser remotely I can see that even this would be too slow on some connections but it invariably works better that Remote desktop which seems to be the preferred approach in the windows world where they don't have much choice. -- It's very glamorous to raise millions of dollars, until it's time for the venture capitalist to suck your eyeballs out. -- Peter Kennedy, chairman of Kraft & Kennedy. -- https://mail.python.org/mailman/listinfo/python-list
Re: The "loop and a half"
alister : > I cant see any reason why I would want to run a web browser remotely I have had that need occasionally. More recently, I wanted to print a PDF document using evince. It took forever for evince to respond over the WAN. I had to resort to other means. > I can see that even this would be too slow on some connections but it > invariably works better that Remote desktop which seems to be the > preferred approach in the windows world where they don't have much > choice. I can't comment on Windows. However, X11's remote access is hardly usable. The problem is it's too low-level ("mechanism, not a policy"). What we'd need is this setup: +-+ | client | +-+ | toolkit | | RPC | +++ | | TCP | +++ | toolkit | | server | +++ | | Local | +--+--+ | Wayland | | compositor | +-+ Unfortunately, what we wil be given is: +-+ | client | +-+ | toolkit | | lib | +++ | | Local | +--+--+ | Wayland | | compositor | +-+ Which will get rid of the network transparency altogether. Marko -- https://mail.python.org/mailman/listinfo/python-list
Re: The "loop and a half"
On 2017-10-09, Marko Rauhamaa wrote: > Grant Edwards : > >> On 2017-10-09, alister via Python-list wrote: >> >>> or if you want the luxury of a GUI editor simply ssh to the remote >>> machine & run the editor there (using X forwarding to route the >>> display to you local PC) >> >> AFAICT, most modern GUI toolkits are no longer usable via X forwarding >> at sub-gigabit network speeds. The toolkit designers have botched >> things up so that even the most trivial operation requires hundreds of >> round-trips between server and client. > > Yep. > > Funny thing is, xterm runs nicely over a 9,600-baud line, but there's no > hope to get Firefox, Evince or the like to run over a 1,500,000 bps > connection. Most of the "old-school" apps that use athena or motif widgets work fine. There are a a couple more modern toolkits that still work right: the last time I tried an fltk, it seemed OK. But, both GTK and QT are hopeless pigs. Xemacs can be built so that it works fine remotely -- but if you're an emacs user you generally don't care. It's simpler to just run emacs on the remote machine via a normal "tty" connection. > Latency is more of an issue than throughput, That's true, I should have been more precise. > indicating that those round-trips are sequential. X11 was designed > to be pipelined but the toolkits can't pipeline themselves. -- Grant Edwards grant.b.edwardsYow! Am I SHOPLIFTING? at gmail.com -- https://mail.python.org/mailman/listinfo/python-list
Re: The "loop and a half"
On 2017-10-09, Marko Rauhamaa wrote: > I can't comment on Windows. However, X11's remote access is hardly > usable. 15 years ago it worked great over 256Kbps DSL links. Even on dialup links it was usable (if a bit clumsy). It's the toolkits that are broken when it comes to remote access. > The problem is it's too low-level ("mechanism, not a policy"). What > we'd need is this setup: > >+-+ >| client | >+-+ >| toolkit | >| RPC | >+++ > | > | TCP > | >+++ >| toolkit | >| server | >+++ > | > | Local > | > +--+--+ > | Wayland | > | compositor | > +-+ But then you need to re-impliment that for each and every toolkit. With the old X11 scheme, it only need to be implimented once. > Unfortunately, what we wil be given is: > >+-+ >| client | >+-+ >| toolkit | >| lib | >+++ > | > | Local > | > +--+--+ > | Wayland | > | compositor | > +-+ > > > Which will get rid of the network transparency altogether. For all practial purposes, X11 network transparancy has been gone for years: it only works for apps that nobody cares about. I still use it occasionally just to verify that a remotely upgraded/installed wxPython app will start up, but it's way too slow to actually _use_ the app. -- Grant Edwards grant.b.edwardsYow! I want the presidency at so bad I can already taste gmail.comthe hors d'oeuvres. -- https://mail.python.org/mailman/listinfo/python-list
Re: The "loop and a half"
Grant Edwards : > On 2017-10-09, Marko Rauhamaa wrote: >> The problem is it's too low-level ("mechanism, not a policy"). What >> we'd need is this setup: >> >>+-+ >>| client | >>+-+ >>| toolkit | >>| RPC | >>+++ >> | >> | TCP >> | >>+++ >>| toolkit | >>| server | >>+++ >> | >> | Local >> | >> +--+--+ >> | Wayland | >> | compositor | >> +-+ > > But then you need to re-impliment that for each and every toolkit. > With the old X11 scheme, it only need to be implimented once. The solution is that the toolkit RPC sends (or is prepared to send) the toolkit server plugin to the generic remote server. In fact, that's how web pages are implemented using JavaScript (with the roles of the server and the client reversed). Marko -- https://mail.python.org/mailman/listinfo/python-list
Is there a way to globally set the print function separator?
I want sep="" to be the default without having to specify it every time I call print. Is that possible? John Black -- https://mail.python.org/mailman/listinfo/python-list
Re: Is there a way to globally set the print function separator?
On 10/9/17 12:22 PM, John Black wrote: I want sep="" to be the default without having to specify it every time I call print. Is that possible? There isn't a way to change the default for print(sep="") globally. Generally when you want better control over the output, you use string formatting. Instead of: print("X is ", x, " and y is ", y, sep="") use: print("X is {} and y is {}".format(x, y)) If you show us your actual print lines, we can give more concrete advice. --Ned. -- https://mail.python.org/mailman/listinfo/python-list
Re: Is there a way to globally set the print function separator?
On 9 October 2017 at 17:22, John Black wrote: > I want sep="" to be the default without having to specify it every time I > call print. Is that possible? def myprint(*args, **kw): print(*args, sep="", **kw) If you want, assign print=myprint. Paul -- https://mail.python.org/mailman/listinfo/python-list
Re: on = style
hum i see clearly with all my python experience, i have more to learn. i never aligned the = but i found it neat looking but discouraged by pep8. glad i did not switch to it and maintained it for sometimes ! thanks for answers ! Abdur-Rahmaan Janhangeer, Mauritius abdurrahmaanjanhangeer.wordpress.com On 9 Oct 2017 10:40, "Abdur-Rahmaan Janhangeer" wrote: > hi just a quick question, why is > > my_pens = 4 > my_pencils = 5 > > is preffered to > > my_pens = 4 > my_pencils = 5 > > *referring to = symbol alignment > > tk ! > > Abdur-Rahmaan Janhangeer, > Mauritius > abdurrahmaanjanhangeer.wordpress.com > -- https://mail.python.org/mailman/listinfo/python-list
Re: Is there a way to globally set the print function separator?
Le 09/10/2017 à 18:22, John Black a écrit : I want sep="" to be the default without having to specify it every time I call print. Is that possible? >>> oldprint = print >>> def print(*args,**kwargs): ... oldprint(*args,**kwargs,sep='') ... >>> print(1,2,3) 123 -- https://mail.python.org/mailman/listinfo/python-list
Re: Is there a way to globally set the print function separator?
John Black wrote: > I want sep="" to be the default without having to specify it every time I > call print. Is that possible? No, but you can replace the print function with your own: >>> print = functools.partial(print, sep="") >>> print("I", "recommend", "you", "choose", "another", "name", "and", "preserve", "your", "sanity") Irecommendyouchooseanothernameandpreserveyoursanity And everybody else's. -- https://mail.python.org/mailman/listinfo/python-list
Re: Is there a way to globally set the print function separator?
On 10/9/2017 12:22 PM, John Black wrote: I want sep="" to be the default without having to specify it every time I call print. Is that possible? John Black Define a replacement print function that makes this the default. Something like (untested, a detail may be wrong): _print = print def print(*args, **kwargs): _print(*args, {'sep':''}.update(kwargs)) -- Terry Jan Reedy -- https://mail.python.org/mailman/listinfo/python-list
Re: Finding Old Posts on Python
download the archive in compressed format. then use notepad++ or sublimetext with option search in files. search for your name ! Abdur-Rahmaan Janhangeer, Mauritius abdurrahmaanjanhangeer.wordpress.com On 8 Oct 2017 03:45, "Cai Gengyang" wrote: > Hello, > > Does anyone know of a way to find all my old posts about Python ? Thanks a > lot! > > GengYang > -- > https://mail.python.org/mailman/listinfo/python-list > -- https://mail.python.org/mailman/listinfo/python-list
Re: Python GUI application embedding a web browser - Options?
Paul Moore said : > On 9 October 2017 at 04:25, wrote: >> Did you find out the answer for that? > > Nothing much beyond the pointer to PyQt (which basically said "a lot > of the info on the web is out of date" so I should check the latest > docs). I didn't take it much further, though, as it was a hobby > project and the learning curve for PyQt (any GUI framework, really) > was a bit high for the amount of spare time I had at the time. > > Paul Have you looked at CEFpython ? It seems to work with all major GUIs (Qt, wx, Tk, gtk..) https://github.com/cztomczak/cefpython/tree/master/examples -- https://mail.python.org/mailman/listinfo/python-list
Re: The "loop and a half"
On Sun, Oct 8, 2017 at 5:36 AM, bartc wrote: > > On 08/10/2017 10:12, Steve D'Aprano wrote: >> >> On Sun, 8 Oct 2017 02:06 am, bartc wrote: >>> I'm getting fed up with this thread now. >> >> >> This thread would be a lot less frustrating if you would enter into it with a >> spirit of open-minded enquiry rather than an overbearing sense of superiority >> that anything others do that you don't must be worthless. > > > Frustrating for whom? > > It seems to me that it's pretty much everyone here who has an overbearing > sense of superiority in that everything that Unix or Linux does is a million > times better than anything else. I follow this list in an effort to learn as much as I can even though I am usually a fish out of water here. But this thread in all its twists and turns and various subject line changes seems to have gotten totally out of hand. Even though I am quoting only part of this one message, there are actually many others that I am responding to here. In my opinion (Honestly admitting my lack of technical competence.), this insatiable thirst on this list to get every bit of technical minutiae exactly correct is doing a severe disservice to the friendliness of this community. Yes, gently correct the (perceived) errors, because we all want to have it right, but please cease this incessant pounding of points (and people) into the ground to prove we are right and they are wrong! I doubt any of this is going to change Bart's mind. Why can we not allow him to make his points, respond to them appropriately, and then let it go when it is clear he has strongly held opinions that are not likely to change? And Bart, when large numbers of technical experts in their fields have spent many hours/months/years, yea, even several decades, developing these software systems, why do you think that you, all by yourself, know better? Can you not see how frustrating this is for people who have spent good chunks of their lives trying to do the best they can on these software systems? Don't you think it is a better approach to perhaps do some self-examination and approach things from a more humble learner's perspective? And BTW, there are many users of non-*nix systems on this list, or who do work on multiple operating system platforms. Can we not let people be who they are, perceived warts (valid or not) and all, and after responding (hopefully gently) to technical errors just let them be??? Peace. -- boB -- https://mail.python.org/mailman/listinfo/python-list
EuroPython 2017: Videos for Tuesday available online
We are pleased to announce the second batch of cut videos for EuroPython 2017. To see the new videos, please head over to our EuroPython YouTube channel and select the "EuroPython 2017" playlist. The new videos start at entry 31 in the playlist. * EuroPython 2017 Videos * http://europython.tv/ In the coming weeks, we will continue to release the other videos currently marked as “private”, in batches of one conference day per week. Enjoy, -- EuroPython 2017 Team http://ep2017.europython.eu/ http://www.europython-society.org/ PS: Please forward or retweet to help us reach all interested parties: https://twitter.com/europython/status/916690691224473601 Thanks. -- https://mail.python.org/mailman/listinfo/python-list
Re: on = style
On 09/10/2017 07:40, Abdur-Rahmaan Janhangeer wrote: hi just a quick question, why is my_pens = 4 my_pencils = 5 is preffered to my_pens = 4 my_pencils = 5 *referring to = symbol alignment I will sometimes line things up, if a block of assignments are related: red = 1 green = 2 blue= 3 There might sometimes be extra maintenance if you then add: turquoise = 4 and have to readjust the others, or you add: yellow= 201 and prefer the number should be aligned right-justified: red = 1 green = 2 blue = 3 turquoise = 4 yellow= 201 but it's not hard. Although it might not be worth doing until a program is finished. Compare to: red = 1 green = 2 blue = 3 turquoise = 4 yellow = 201 -- bartc -- https://mail.python.org/mailman/listinfo/python-list
Re: Is there a way to globally set the print function separator?
In article , __pete...@web.de says... > > John Black wrote: > > > I want sep="" to be the default without having to specify it every time I > > call print. Is that possible? > > No, but you can replace the print function with your own: > > >>> print = functools.partial(print, sep="") > >>> print("I", "recommend", "you", "choose", "another", "name", "and", > "preserve", "your", "sanity") > Irecommendyouchooseanothernameandpreserveyoursanity > > And everybody else's. print=functools.partial(print, sep="") NameError: name 'functools' is not defined John Black -- https://mail.python.org/mailman/listinfo/python-list
Re: Is there a way to globally set the print function separator?
On Tue, Oct 10, 2017 at 7:40 AM, John Black wrote: > In article , > __pete...@web.de says... >> >> John Black wrote: >> >> > I want sep="" to be the default without having to specify it every time I >> > call print. Is that possible? >> >> No, but you can replace the print function with your own: >> >> >>> print = functools.partial(print, sep="") >> >>> print("I", "recommend", "you", "choose", "another", "name", "and", >> "preserve", "your", "sanity") >> Irecommendyouchooseanothernameandpreserveyoursanity >> >> And everybody else's. > > print=functools.partial(print, sep="") > NameError: name 'functools' is not defined It's a module you can import. ChrisA -- https://mail.python.org/mailman/listinfo/python-list
Re: Is there a way to globally set the print function separator?
In article , python@example.invalid says... > > Le 09/10/2017 à 18:22, John Black a écrit : > > I want sep="" to be the default without having to specify it every time I > > call print. Is that possible? > > >>> oldprint = print > >>> def print(*args,**kwargs): > ... oldprint(*args,**kwargs,sep='') > ... > >>> print(1,2,3) > 123 Winner! Thanks all. I want to make sure I understand what this line is doing: > oldprint = print Experimenting, I find this is not a rename because I can use both function names. It looks it literally copies the function "print" to another function called "oldprint". But now, I have a way to modify the builtin funciton "print" by referencing oldprint. Without oldprint, I have no way to directly modify print? For example, based on your post, I tried: def print(*args, **kw): print(*args, sep='', **kw) meaning print calls print (itself) with sep=''. But this failed and I guess the reason is that it would keep calling itself recursively adding sep='' each time? Thanks. John Black -- https://mail.python.org/mailman/listinfo/python-list
Re: Is there a way to globally set the print function separator?
On 2017-10-09, John Black wrote: > I want to make sure I understand what this line is doing: > >> oldprint = print > > Experimenting, I find this is not a rename because I can use both > function names. Right it's not _changing_ a name. It's _adding_ a name. > It looks it literally copies the function "print" to > another function called "oldprint". No, it binds a new name of 'oldprint' to the function to which 'print' is bound. It does not create a second function, nor does it remove the binding of the name 'print' to that function. It just adds a second name that's also bound to that function. > But now, I have a way to modify the builtin funciton "print" by > referencing oldprint. Without oldprint, I have no way to directly > modify print? Well... you can still access the builtin print via the module that contains it: >>> def print(*args, **kw): ... __builtins__.print(*args, sep='', **kw) ... >>> print(1,2,3) However, anytime you find yourself using double underscore stuff you should think to yourself "I should find a better way to do that." > def print(*args, **kw): > print(*args, sep='', **kw) > > meaning print calls print (itself) with sep=''. But this failed and I > guess the reason is that it would keep calling itself recursively adding > sep='' each time? Yep. Just define a new function with a new name: def myprint(*args, **kw): print(*args, sep='', **kw) Redefining builtins is just going get you sworn at down the road a bit. If not by yourself, then by somebody else... -- Grant Edwards grant.b.edwardsYow! Used staples are good at with SOY SAUCE! gmail.com -- https://mail.python.org/mailman/listinfo/python-list
Re: Is there a way to globally set the print function separator?
On Mon, Oct 9, 2017 at 10:04 PM, John Black wrote: > In article , python@example.invalid says... >> >> Le 09/10/2017 à 18:22, John Black a écrit : >> > I want sep="" to be the default without having to specify it every time I >> > call print. Is that possible? >> >> >>> oldprint = print >> >>> def print(*args,**kwargs): >> ... oldprint(*args,**kwargs,sep='') >> ... >> >>> print(1,2,3) >> 123 > > Winner! Thanks all. functools.partial(print, sep='') is the winner, IMO. Or even code that use kwargs.setdefault('sep', ''). The above code is wrong in a way that leads to a TypeError. Can you see the problem? -- https://mail.python.org/mailman/listinfo/python-list
Re: The "loop and a half"
On 2017-10-09 09:44, Mikhail V wrote: Have you ever worked on a slow remote session where a GUI is completely impracticable (or maybe even unavailable), and redrawing the screen is too expensive to do all the time? >>> >>> So where does the redrawing happen? The machine youre sitting on (let's >>> call it 'A') and send remote commands or retrieving text files? Or the >>> redrawing must be synced on both A and >>> the remote machine? If so, then why so? > > Peter J. Holzer wrote: > >> Because you want to see what you are typing. Imagine you are logged into >> a server on the other side of the world. You want to edit a file on that >> machine (for example a configuration file for the web server). You >> invoke the editor on that server. > > I've never done this, but if one told me to edit a file, > my first attempt would be like: > - get read/write access to the file system > - browse it (e.g. some file browser plugin?) > - get the file to the local machine > - edit locally > - write it back to the remote machine I've mentioned that possibility, but as I've also mentioned it may not even be possible, and even if it is, it feels clunky to me. I'm already on the server because I'm investigating an issue. I can simply edit the file there. Why should I switch to a different tool (e.g. WinSCP), open another connection, navigate to a directory again, copy a file, edit it, copy it back (ok, the actual copying back and forth may happen automatically, so I don't have to do that)? Of course I am assuming that I have an editor I'm familiar with on the server. For me this is almost always the case (I use vi (or rather vim) - yes, I'm currently writing this posting with vim). For a Windows user this will usually not be the case: There will be no Notepad++, Atom or PyCharm installed on a typical Linux server. (Of course there are those who maintain that you should never ever log in to server: All interaction should be through APIs and management systems. That may be true if you have thousands of servers. If you have a few dozen I think that to get a management system into place which is even close to the linux CLI tools in veratility is way too much work.) >>> And not in a nice editor with normal fonts? >>> Am i missing something or your 'A' machine cannot use graphics? > >> ... The server may not be able to >> (it's a server, why would anyone install a GUI on it?) > > If I ever work on it (locally) why would I want a GUI on it? > o_O I'm not sure if I'm getting you. > You mean probably a server which is never worked on locally? Typically yes. T usually am sitting in front of a server just long enough to make sure I have a network connection. Then I go back to my office and continue from there. Server rooms are loud, drafty, and either too cold or too warm. But it really doesn't matter to me: On the text console I can use exactly the same programs that I would use remotely over ssh. The only differences are that there is only one window and I can't resize it. >> streaming the screen contents of a rich GUI around the world may be not >> be possible for bandwidth or delay reasons. > Sure, streaming video consumes a lot, but that is what one tries to > avoid if under limitations so streaming messages only is faster. Streaming video is basically what RDP or VNC are. A command line shell is closer to streaming messages. X11 is really message-based but it's slow. hp -- _ | Peter J. Holzer| Fluch der elektronischen Textverarbeitung: |_|_) || Man feilt solange an seinen Text um, bis | | | h...@hjp.at | die Satzbestandteile des Satzes nicht mehr __/ | http://www.hjp.at/ | zusammenpaßt. -- Ralph Babel -- https://mail.python.org/mailman/listinfo/python-list
Re: Is there a way to globally set the print function separator?
In article , eryk...@gmail.com says... > > On Mon, Oct 9, 2017 at 10:04 PM, John Black wrote: > > In article , python@example.invalid says... > >> > >> Le 09/10/2017 à 18:22, John Black a écrit : > >> > I want sep="" to be the default without having to specify it every time I > >> > call print. Is that possible? > >> > >> >>> oldprint = print > >> >>> def print(*args,**kwargs): > >> ... oldprint(*args,**kwargs,sep='') > >> ... > >> >>> print(1,2,3) > >> 123 > > > > Winner! Thanks all. > > functools.partial(print, sep='') is the winner, IMO. Ok, I got that working too after someone told me I have to import functools. Can you explain what it means? It looks like it is not defining another function like the other solutions but is truly changing the defaults for the existing function print? John Black -- https://mail.python.org/mailman/listinfo/python-list
Re: Lies in education [was Re: The "loop and a half"]
On Tue, 10 Oct 2017 06:06 am, Stefan Ram wrote: > In his book about programming, Bjarne Stroustrup writes: > > |We try hard to avoid "white lies"; that is, we refrain from > |oversimplified explanations that are clear and easy to > |understand, but not true in the context of real languages and > |real problems. Bjarne Stroustrup is famous for designing one of the most heavyweight, baraque, hard-to-understand, difficult-to-use programming languages in common use. While C++ has many excellent features, and is constrained by the need to be compatible with C, I don't think many people believe that it is a well-designed language. But even if it were the best language in the world, and Stroustrup the greatest language designer in the history of computing, what makes you think that he knows anything about teaching? -- 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