Re: [Tutor] call key on_press event multiple times when key is held down

2017-07-04 Thread eryk sun
On Tue, Jul 4, 2017 at 8:50 AM, Carlton Banks wrote: > I am using pynput for keyboard events You could use an event that enables a recording loop. The on_press and on_release callbacks of the Listener [1] would set() and clear() this event, respectively. For

Re: [Tutor] Fwd: Re: call key on_press event multiple times when key is held down

2017-07-04 Thread Carlton Banks
> >> Interesting solution, but still find a bit "dirty hackish” >> to involve a timer in this.. I guess it just would be neat if >> it just worked as i thought it to be. But i guess i have to look into >> curses. > > A timer based loop is actually the standard pattern for > implementing a loo

Re: [Tutor] Fwd: Re: call key on_press event multiple times when key is held down

2017-07-04 Thread Alan Gauld via Tutor
On 04/07/17 12:00, Alan Gauld via Tutor wrote: >> the library you are using, I normally just use the standard >> library for such things, or build a simple GUI… > > Standard library being?.. The Python standard library that ships with Python and is documented on python.org. As in: >> There are

[Tutor] Fwd: Re: call key on_press event multiple times when key is held down

2017-07-04 Thread Alan Gauld via Tutor
Forwarding to Tutor list Please always use reply-All or reply-List to respond to tutor posts. Forwarded Message > Den 4. jul. 2017 kl. 11.35 skrev Alan Gauld via Tutor : > > On 04/07/17 09:50, Carlton Banks wrote: >> I am trying to record from my microphone while i press do

Re: [Tutor] [Python2.7] Convert (2,188,1) into (188,1)

2017-07-04 Thread Albert-Jan Roskam
From: Tutor [tutor-bounces+sjeik_appie=hotmail@python.org] on behalf of Alan Gauld via Tutor [tutor@python.org] Sent: Tuesday, July 4, 2017 8:37 AM To: tutor@python.org Subject: Re: [Tutor] [Python2.7] Convert (2,188,1) into (188,1) On 28/06/17 16:48,

Re: [Tutor] call key on_press event multiple times when key is held down

2017-07-04 Thread Alan Gauld via Tutor
On 04/07/17 09:50, Carlton Banks wrote: > I am trying to record from my microphone while i press down a button, First question is which OS? That makes a big difference in this kind of scenario. > the library I am using is not able to detect on hold event. There isn't really any concept of a hol

[Tutor] call key on_press event multiple times when key is held down

2017-07-04 Thread Carlton Banks
I am trying to record from my microphone while i press down a button, problem is that the library I am using is not able to detect on hold event. It only detect on press, which happens once, which means that the microphone only records one sample.. import pyaudio import wave from pynput import

Re: [Tutor] Not returning out the series

2017-07-04 Thread Sibylle Koczian
Am 04.07.2017 um 04:40 schrieb Rafael Skovron: Hi as a challenge I have got to sum a series i / (i+1). My code isn't summing right. Any ideas why? def main(): print("{0:15s}{1:20s}".format("i","m(i)")) for i in range(1,20): print("{0:<15d}{1:<20.4f}".format(i,m(i))) def m(i)

Re: [Tutor] [Python2.7] Convert (2,188,1) into (188,1)

2017-07-04 Thread Alan Gauld via Tutor
On 28/06/17 16:48, Allan Tanaka via Tutor wrote: > Hi. I have array shape like: (2,188,1). I assume this is a numpy array rather than the standard library array? If so consider asking on the scipy/numpy support forum for more specialised help. > I want to make it like this: (188,1). I try that

Re: [Tutor] Not returning out the series

2017-07-04 Thread Alan Gauld via Tutor
On 04/07/17 03:40, Rafael Skovron wrote: > def m(i): > total = 0 > for i in range(1,i+1,1): > total+=(i/(i+1)) > return total convert the numerator to a float. Otherwise you are using integer division. (I'm guessing you are running Python 2.7?) You could also import division

[Tutor] Not returning out the series

2017-07-04 Thread Rafael Skovron
Hi as a challenge I have got to sum a series i / (i+1). My code isn't summing right. Any ideas why? def main(): print("{0:15s}{1:20s}".format("i","m(i)")) for i in range(1,20): print("{0:<15d}{1:<20.4f}".format(i,m(i))) def m(i): total = 0 for i in range(1,i+1,1):