Re: Why doesn't Python include non-blocking keyboard input function?

2016-10-26 Thread Steven D'Aprano
On Thursday 27 October 2016 12:12, BartC wrote: > I don't > understand the argument that a language shouldn't have a basic keyboard > API because some computers it could run on might not have a keyboards. That's not the argument. The argument is that Python has a basic keyboard API: raw_input (i

Re: Why doesn't Python include non-blocking keyboard input function?

2016-10-26 Thread Marko Rauhamaa
Grant Edwards : > I've offered a few times to extend the Linux pty driver to support the > same set of ioctl calls that a tty does (so that it could be used in > place of a tty generally), but I've never gotten any response. Ah, Linux kernel politics are Byzantine. It's virtually impossible to get

Re: Why doesn't Python include non-blocking keyboard input function?

2016-10-26 Thread Marko Rauhamaa
Terry Reedy : > On 10/26/2016 8:33 AM, Marko Rauhamaa wrote: >> Maybe there should be some way to get the raw events from the PTY. > > PTY? Must be Linux-specific. Most beginners are not on Linux. A PTY is an emulated console (https://en.wikipedia.org/wiki/Pseudoterminal>). I don't know Windows

Re: Why doesn't Python include non-blocking keyboard input function?

2016-10-26 Thread Grant Edwards
On 2016-10-27, Paul Rubin wrote: > Terry Reedy writes: > >> Today, ethernet-connected *nix servers have no keyboard, mouse, or >> even a directly connected terminal. > > Usually you ssh into them and connect to a pty which supports the > same ioctls that a real terminal would. On all the Unixes/

Re: Why doesn't Python include non-blocking keyboard input function?

2016-10-26 Thread Paul Rubin
Terry Reedy writes: > Today, ethernet-connected *nix servers have no > keyboard, mouse, or even a directly connected terminal. Usually you ssh into them and connect to a pty which supports the same ioctls that a real terminal would. I use screen editors over ssh all the time, not to mention filt

Re: Why doesn't Python include non-blocking keyboard input function?

2016-10-26 Thread eryk sun
On Wed, Oct 26, 2016 at 11:39 AM, Dennis Lee Bieber wrote: > Curses tends to not be available on Windows as M$ hasn't implemented a > compatible console driver. The PDCurses library supports the Windows console. Christoph Gohlke distributes a curses extension module based on it: http://www.

Re: Why doesn't Python include non-blocking keyboard input function?

2016-10-26 Thread Terry Reedy
On 10/26/2016 11:00 AM, BartC wrote: On 26/10/2016 13:33, Marko Rauhamaa wrote: Say you want to implement a simple, character-based shooting game where the two guns are operated by the [Shift] keys. Unfortunately, the Unix terminal API doesn't make that possible. You need to get the keyboard e

Re: Why doesn't Python include non-blocking keyboard input function?

2016-10-26 Thread BartC
On 27/10/2016 00:30, Terry Reedy wrote: On 10/26/2016 7:18 AM, BartC wrote: Can tkinter do it without creating a distracting pop-up window at the same time? Yes. I already showed how on this thread. Of course, for some text appications, one would be better off with a Text widget than with t

Re: Why doesn't Python include non-blocking keyboard input function?

2016-10-26 Thread Terry Reedy
On 10/26/2016 8:33 AM, Marko Rauhamaa wrote: BartC : Say you want to implement a simple, character-based shooting game where the two guns are operated by the [Shift] keys. Unfortunately, the Unix terminal API doesn't make that possible. You need to get the keyboard events from some other API.

Re: Why doesn't Python include non-blocking keyboard input function?

2016-10-26 Thread Terry Reedy
On 10/26/2016 7:18 AM, BartC wrote: Can tkinter do it without creating a distracting pop-up window at the same time? Yes. I already showed how on this thread. Of course, for some text appications, one would be better off with a Text widget than with the system-specific console. Bart, you

Re: multiprocess passing arguments double asterisks

2016-10-26 Thread MRAB
On 2016-10-26 21:44, pic8...@gmail.com wrote: On Monday, October 24, 2016 at 12:39:47 PM UTC-5, Thomas Nyberg wrote: On 10/24/2016 12:45 PM, pic8...@gmail.com wrote: > Thanks for the reply. > > The code snippet given by Peter is not very clear > > I would like to multiprocess a function which is

thread local storage

2016-10-26 Thread Joseph L. Casale
Looks like the shipped implementation doesn't give access to all the discrete copies of tls for us in a case where a context manager needs to perform any cleanup. Does something exists where I can leverage this feature or do I need to roll my own? Thanks, jlc -- https://mail.python.org/mailman

Re: Reversing \N{...} notation?

2016-10-26 Thread Peter Otten
Tim Chase wrote: > On 2016-10-25 20:14, Peter Otten wrote: >> Tim Chase wrote: >> > I like the clarity of using the "\N{...}" notation when creating >> > string literals involving Unicode chars. >> > >> > Is there a built-in way to get such strings back from Python? >> >> >>> 'mañana'.encode("as

Re: multiprocess passing arguments double asterisks

2016-10-26 Thread pic8690
On Monday, October 24, 2016 at 12:39:47 PM UTC-5, Thomas Nyberg wrote: > On 10/24/2016 12:45 PM, pic8...@gmail.com wrote: > > Thanks for the reply. > > > > The code snippet given by Peter is not very clear > > > > I would like to multiprocess a function which is written in python of the > > form b

Re: Reversing \N{...} notation?

2016-10-26 Thread Tim Chase
On 2016-10-25 20:14, Peter Otten wrote: > Tim Chase wrote: > > I like the clarity of using the "\N{...}" notation when creating > > string literals involving Unicode chars. > > > > Is there a built-in way to get such strings back from Python? > > >>> 'mañana'.encode("ascii", "namereplace").decode

Re: Why doesn't Python include non-blocking keyboard input function?

2016-10-26 Thread BartC
On 26/10/2016 13:33, Marko Rauhamaa wrote: BartC : On 26/10/2016 05:44, Marko Rauhamaa wrote: (I've implemented 'keyboards' both on-screen, and on the surface of digitising tablets (also with a hacked Casio calculator pcb when I couldn't afford a real one). With all of those I was mainly intere

Re: How to use two threads (GUI and backend)

2016-10-26 Thread Marko Rauhamaa
Chris Angelico : > Python-the-language doesn't permit those kinds of rewrites. [Citation needed] Is there something here, perhaps? https://docs.python.org/3/library/concurrency.html> Marko -- https://mail.python.org/mailman/listinfo/python-list

Re: How to use two threads (GUI and backend)

2016-10-26 Thread Chris Angelico
On Thu, Oct 27, 2016 at 1:42 AM, Marko Rauhamaa wrote: > Chris Angelico : >> And since Python doesn't rewrite the code, you don't have a problem. > > Do you mean Python or CPython? > > And how do you know? Both, and I know because Python-the-language doesn't permit those kinds of rewrites. PyPy d

Re: How to use two threads (GUI and backend)

2016-10-26 Thread Marko Rauhamaa
Chris Angelico : > And since Python doesn't rewrite the code, you don't have a problem. Do you mean Python or CPython? And how do you know? Marko -- https://mail.python.org/mailman/listinfo/python-list

Re: Qtimer and extra argument

2016-10-26 Thread luca72 via Python-list
thanks -- https://mail.python.org/mailman/listinfo/python-list

Re: How to use two threads (GUI and backend)

2016-10-26 Thread Chris Angelico
On Thu, Oct 27, 2016 at 1:21 AM, Marko Rauhamaa wrote: > Analogous code in C or Java would not be guaranteed to finish if func1() > and func2() were in different execution contexts. In fact, it would be > almost guaranteed to hang. > > That is because the compiler can see that "active" cannot chan

Re: How to use two threads (GUI and backend)

2016-10-26 Thread Marko Rauhamaa
Chris Angelico : > On Thu, Oct 27, 2016 at 12:37 AM, Marko Rauhamaa wrote: >> I don't know what "Global state is shared across all threads" means >> in this context. It sounds like something that would be true for, >> say, Java and C as well. However, those languages don't promise to >> propagate

Re: How to use two threads (GUI and backend)

2016-10-26 Thread jmp
On 10/26/2016 02:45 PM, pozz wrote: Il 26/10/2016 13:16, jmp ha scritto: [...] I suggest you write a GUI that make synchronouscalls to a remote application, if possible. If the remote app is in python, you have access to remote protocols already written for you, Pyro is one of them, you can

Re: lxml and xpath(?)

2016-10-26 Thread Peter Otten
Doug OLeary wrote: > Hey; > > Reasonably new to python and incredibly new to xml much less trying to > parse it. I need to identify cluster nodes from a series of weblogic xml > configuration files. I've figured out how to get 75% of them; now, I'm > going after the edge case and I'm unsure how t

Re: How to use two threads (GUI and backend)

2016-10-26 Thread Chris Angelico
On Thu, Oct 27, 2016 at 12:37 AM, Marko Rauhamaa wrote: > Chris Angelico : > >> On Wed, Oct 26, 2016 at 11:58 PM, Marko Rauhamaa wrote: >>> I can't think of a valid program that could take advantage of this >>> primitive guarantee of Python's. For example, there is no "volatile" >>> in Python so

Re: How to use two threads (GUI and backend)

2016-10-26 Thread Marko Rauhamaa
Chris Angelico : > On Wed, Oct 26, 2016 at 11:58 PM, Marko Rauhamaa wrote: >> I can't think of a valid program that could take advantage of this >> primitive guarantee of Python's. For example, there is no "volatile" >> in Python so you can't coordinate Python threads safely without >> proper syn

Re: How to use two threads (GUI and backend)

2016-10-26 Thread Chris Angelico
On Thu, Oct 27, 2016 at 12:02 AM, Marko Rauhamaa wrote: > pozz : > >> The real problem is that retrieving status from remote device is a >> slow operation. If the GUI thread blocks waiting for the answer, the >> GUI blocks and the user complains. > > Correct. Obnoxious, blocking APIs abound. > > H

Re: Qtimer and extra argument

2016-10-26 Thread Phil Thompson
On 26 Oct 2016, at 1:29 pm, luca72 via Python-list wrote: > > I get () missing 1 required positional argument: 's' Sorry, it should have been... lambda: self.metto_testo(testo) Phil -- https://mail.python.org/mailman/listinfo/python-list

Re: How to use two threads (GUI and backend)

2016-10-26 Thread Marko Rauhamaa
pozz : > The real problem is that retrieving status from remote device is a > slow operation. If the GUI thread blocks waiting for the answer, the > GUI blocks and the user complains. Correct. Obnoxious, blocking APIs abound. However, I have usually used processes (instead of threads) to encapsu

Re: How to use two threads (GUI and backend)

2016-10-26 Thread Chris Angelico
On Wed, Oct 26, 2016 at 11:58 PM, Marko Rauhamaa wrote: > In practice, this coherency has been implemented in CPython with a > global lock (GIL). CPython programs are effectively single-threaded. > They only let go of the lock when they are performing a system call. > > I can't think of a valid pr

Re: How to use two threads (GUI and backend)

2016-10-26 Thread Marko Rauhamaa
pozz : > Il 26/10/2016 13:27, Antoon Pardon ha scritto: >> Op 26-10-16 om 12:22 schreef pozz: >>> Is it safe to access this variable from two different threads? >>> Should I implement a safer and more complex mechanism? If yes, what >>> mechanism? >> >> Accessing from multiple thread shouldn't be

Re: How to use two threads (GUI and backend)

2016-10-26 Thread pozz
Il 26/10/2016 13:16, jmp ha scritto: [...] I suggest you write a GUI that make synchronouscalls to a remote application, if possible. If the remote app is in python, you have access to remote protocols already written for you, Pyro is one of them, you can skip the low level communication part

Re: How to use two threads (GUI and backend)

2016-10-26 Thread pozz
Il 26/10/2016 13:27, Antoon Pardon ha scritto: Op 26-10-16 om 12:22 schreef pozz: Il 26/10/2016 09:13, pozz ha scritto: [...] When the user press Start button (the pressed handler is in the GUI class): self.comm_active = True threading.Thread(target=self.comm_thread).start() The backend t

Re: Why doesn't Python include non-blocking keyboard input function?

2016-10-26 Thread Marko Rauhamaa
BartC : > On 26/10/2016 05:44, Marko Rauhamaa wrote: > (I've implemented 'keyboards' both on-screen, and on the surface of > digitising tablets (also with a hacked Casio calculator pcb when I > couldn't afford a real one). With all of those I was mainly interested > in key events, not the details.

Re: UDP decode

2016-10-26 Thread Julian Madoz
Thanks for response! I don't know what can appear because the values changes 30 times per second. I only know the format. -- https://mail.python.org/mailman/listinfo/python-list

Re: Qtimer and extra argument

2016-10-26 Thread luca72 via Python-list
I get () missing 1 required positional argument: 's' -- https://mail.python.org/mailman/listinfo/python-list

Re: Why doesn't Python include non-blocking keyboard input function?

2016-10-26 Thread BartC
On 26/10/2016 05:44, Marko Rauhamaa wrote: BartC : Some people want to work at low level, without needing to drag in a GUI, and want to do something as simple as finding out if a button has been pressed on a standard peripheral that nearly every computer has. It can't be that hard! I don't c

Re: How to use two threads (GUI and backend)

2016-10-26 Thread Antoon Pardon
Op 26-10-16 om 12:22 schreef pozz: > Il 26/10/2016 09:13, pozz ha scritto: > > [...] >> When the user press Start button (the pressed handler is in the GUI >> class): >> >> self.comm_active = True >> threading.Thread(target=self.comm_thread).start() >> >> The backend thread is: >> >> def comm

Re: Why doesn't Python include non-blocking keyboard input function?

2016-10-26 Thread BartC
On 26/10/2016 02:02, Steve D'Aprano wrote: On Tue, 25 Oct 2016 09:02 pm, BartC wrote: raw_input('Press the Enter key to continue... ') Which doesn't work on Python 3. So even here, making it easy by using line-input, it's not so straightforward. Really, Bart? You're stymied by the change of

Re: How to use two threads (GUI and backend)

2016-10-26 Thread jmp
On 10/26/2016 12:22 PM, pozz wrote: Il 26/10/2016 09:13, pozz ha scritto: > [...] When the user press Start button (the pressed handler is in the GUI class): self.comm_active = True threading.Thread(target=self.comm_thread).start() The backend thread is: def comm_thread(self): whil

[RELEASE] ‘python-daemon’ version 2.1.2 released

2016-10-26 Thread Ben Finney
Howdy all, I am pleased to announce the release of version 2.1.2 of the ‘python-daemon’ library. The current release is always available at https://pypi.python.org/pypi/python-daemon/>. Significant changes since the previous version == Additions: *

Re: How to use two threads (GUI and backend)

2016-10-26 Thread pozz
Il 26/10/2016 09:13, pozz ha scritto: > [...] When the user press Start button (the pressed handler is in the GUI class): self.comm_active = True threading.Thread(target=self.comm_thread).start() The backend thread is: def comm_thread(self): while self.comm_active: self.device.

Re: Qtimer and extra argument

2016-10-26 Thread Phil Thompson
On 26 Oct 2016, at 10:36 am, luca72 via Python-list wrote: > > Hello i hope that yo can reply to this question also if the argument is pyqt > > i have a simple test: > def start_timer(self): >self.timer = QTimer() >testo = 'pressed' >self.timer.singleShot(1000, self.mett

Re: ImportError: No module named 'simstring'

2016-10-26 Thread Ben Finney
Daiyue Weng writes: > Hi, I am trying to install simstring on Windows 10 through pip/conda, but > couldn't find the package. Pip installs packages listed on the Python Package Index (PyPI) https://pypi.python.org/>, do any of the search results there match what you want? -- \ “Pinky,

Qtimer and extra argument

2016-10-26 Thread luca72 via Python-list
Hello i hope that yo can reply to this question also if the argument is pyqt i have a simple test: def start_timer(self): self.timer = QTimer() testo = 'pressed' self.timer.singleShot(1000, self.metto_testo) def test(self, testo): self.lineEdit.setText(testo)

ImportError: No module named 'simstring'

2016-10-26 Thread Daiyue Weng
Hi, I am trying to install simstring on Windows 10 through pip/conda, but couldn't find the package. I am using Pycharm + Anaconda, so I am wondering is it possible to install simstring on Windows, and how. Cheers -- https://mail.python.org/mailman/listinfo/python-list

Re: How to use two threads (GUI and backend)

2016-10-26 Thread pozz
Il 26/10/2016 09:13, pozz ha scritto: > [...] What is the best approach to use in my scenario (GUI and backend communication)? I just found this[1] page, where the thread approach is explained with the following code: --- import threading import time from gi.repository import GLib, Gt

How to use two threads (GUI and backend)

2016-10-26 Thread pozz
I'm designing a GUI application in Python (with pyGObject, so GTK). The application communicates with a remote device (connected through RS232, but it could be on Internet) to retrieve its status and set/get its configuration. When the user press "Start" button, the application starts sending