How can I exit the program on specified user input when in another window? /u/timosaurus-rex Python Education

How can I exit the program on specified user input when in another window? /u/timosaurus-rex Python Education

I have a program that plays a mobile game on an emulator for me, so the first thing it does is open another window over VSCode.

It moves the mouse around quite fast so I can’t always get back to VSCode to exit the program.

Can someone help me figure out a way of having the program recognise a specified user input (like pressing ‘q’ or something) even when I’m in another window and then exiting the program when that is deteced?

I was thinking some kind of multi-threaded monitor daemon to just constantly check if ‘q’ has been pressed but I’m quite new to this so would love to hear of any better suggestions.

FYI Ctrl+C doesn’t work when I’m in another window, already tried that.

submitted by /u/timosaurus-rex
[link] [comments]

​r/learnpython I have a program that plays a mobile game on an emulator for me, so the first thing it does is open another window over VSCode. It moves the mouse around quite fast so I can’t always get back to VSCode to exit the program. Can someone help me figure out a way of having the program recognise a specified user input (like pressing ‘q’ or something) even when I’m in another window and then exiting the program when that is deteced? I was thinking some kind of multi-threaded monitor daemon to just constantly check if ‘q’ has been pressed but I’m quite new to this so would love to hear of any better suggestions. FYI Ctrl+C doesn’t work when I’m in another window, already tried that. submitted by /u/timosaurus-rex [link] [comments] 

I have a program that plays a mobile game on an emulator for me, so the first thing it does is open another window over VSCode.

It moves the mouse around quite fast so I can’t always get back to VSCode to exit the program.

Can someone help me figure out a way of having the program recognise a specified user input (like pressing ‘q’ or something) even when I’m in another window and then exiting the program when that is deteced?

I was thinking some kind of multi-threaded monitor daemon to just constantly check if ‘q’ has been pressed but I’m quite new to this so would love to hear of any better suggestions.

FYI Ctrl+C doesn’t work when I’m in another window, already tried that.

submitted by /u/timosaurus-rex
[link] [comments]  I have a program that plays a mobile game on an emulator for me, so the first thing it does is open another window over VSCode. It moves the mouse around quite fast so I can’t always get back to VSCode to exit the program. Can someone help me figure out a way of having the program recognise a specified user input (like pressing ‘q’ or something) even when I’m in another window and then exiting the program when that is deteced? I was thinking some kind of multi-threaded monitor daemon to just constantly check if ‘q’ has been pressed but I’m quite new to this so would love to hear of any better suggestions. FYI Ctrl+C doesn’t work when I’m in another window, already tried that. submitted by /u/timosaurus-rex [link] [comments]

Read more

Why does Numpy apply functions in a way that loses array dimensionality? /u/Schnauzerofdoom Python Education

Why does Numpy apply functions in a way that loses array dimensionality? /u/Schnauzerofdoom Python Education

In other words, I’m wondering why keepdims is False by default on functions like np.max() or np.sum() when you supply an axis. Seems to me like retaining dimensions would be preferable in pretty much every case but I don’t have enough experience to know if that’s actually true. In fact I can’t even figure out why keepdims would need to be an argument to begin with. If I wanted to sum some data like:

inputs =

[[1 2 3]

[1 2 3]

[1 2 3]]

And let’s say I ran

np.sum(inputs, axis=1)

Why would I ever want the output to be this:

[3 6 9]

Rather than this?

[[3]

[6]

[9]]

Even if you want it that way you can just transpose it afterward, right? I feel like there must be a good reason Numpy does this but I can’t figure out why.

submitted by /u/Schnauzerofdoom
[link] [comments]

​r/learnpython In other words, I’m wondering why keepdims is False by default on functions like np.max() or np.sum() when you supply an axis. Seems to me like retaining dimensions would be preferable in pretty much every case but I don’t have enough experience to know if that’s actually true. In fact I can’t even figure out why keepdims would need to be an argument to begin with. If I wanted to sum some data like: inputs = [[1 2 3] [1 2 3] [1 2 3]] And let’s say I ran np.sum(inputs, axis=1) Why would I ever want the output to be this: [3 6 9] Rather than this? [[3] [6] [9]] Even if you want it that way you can just transpose it afterward, right? I feel like there must be a good reason Numpy does this but I can’t figure out why. submitted by /u/Schnauzerofdoom [link] [comments] 

In other words, I’m wondering why keepdims is False by default on functions like np.max() or np.sum() when you supply an axis. Seems to me like retaining dimensions would be preferable in pretty much every case but I don’t have enough experience to know if that’s actually true. In fact I can’t even figure out why keepdims would need to be an argument to begin with. If I wanted to sum some data like:

inputs =

[[1 2 3]

[1 2 3]

[1 2 3]]

And let’s say I ran

np.sum(inputs, axis=1)

Why would I ever want the output to be this:

[3 6 9]

Rather than this?

[[3]

[6]

[9]]

Even if you want it that way you can just transpose it afterward, right? I feel like there must be a good reason Numpy does this but I can’t figure out why.

submitted by /u/Schnauzerofdoom
[link] [comments]  In other words, I’m wondering why keepdims is False by default on functions like np.max() or np.sum() when you supply an axis. Seems to me like retaining dimensions would be preferable in pretty much every case but I don’t have enough experience to know if that’s actually true. In fact I can’t even figure out why keepdims would need to be an argument to begin with. If I wanted to sum some data like: inputs = [[1 2 3] [1 2 3] [1 2 3]] And let’s say I ran np.sum(inputs, axis=1) Why would I ever want the output to be this: [3 6 9] Rather than this? [[3] [6] [9]] Even if you want it that way you can just transpose it afterward, right? I feel like there must be a good reason Numpy does this but I can’t figure out why. submitted by /u/Schnauzerofdoom [link] [comments]

Read more

Best language to develop mobile apps which run Python? /u/Gotz16 Python Education

Best language to develop mobile apps which run Python? /u/Gotz16 Python Education

Hi, I want to code a lot of mobile Apps that runs python scrypts so bad but I am not sure if I should learn Kotlin, React Native or what. I really dont mind about the language itself but its compatibility with Python and how easy it would be to run it on the language. Thanks in advice!

submitted by /u/Gotz16
[link] [comments]

​r/learnpython Hi, I want to code a lot of mobile Apps that runs python scrypts so bad but I am not sure if I should learn Kotlin, React Native or what. I really dont mind about the language itself but its compatibility with Python and how easy it would be to run it on the language. Thanks in advice! submitted by /u/Gotz16 [link] [comments] 

Hi, I want to code a lot of mobile Apps that runs python scrypts so bad but I am not sure if I should learn Kotlin, React Native or what. I really dont mind about the language itself but its compatibility with Python and how easy it would be to run it on the language. Thanks in advice!

submitted by /u/Gotz16
[link] [comments]  Hi, I want to code a lot of mobile Apps that runs python scrypts so bad but I am not sure if I should learn Kotlin, React Native or what. I really dont mind about the language itself but its compatibility with Python and how easy it would be to run it on the language. Thanks in advice! submitted by /u/Gotz16 [link] [comments]

Read more

turning my multithreading code into multiprocessing /u/qhelspil Python Education

turning my multithreading code into multiprocessing /u/qhelspil Python Education

i want to record 2 audios at the same time.

using multithreadind this code works fine

import sounddevice as sd from scipy.io.wavfile import write import numpy as np import threading fs = 44100 duration = 5 filename1 = ‘output.wav’ filename2 = ‘second_output.wav’ def record_audio(fs, duration, filename): print(f”Recording first audio to {filename}…”) recording = sd.rec(int(duration * fs), samplerate=fs, channels=2, dtype=’float64′) sd.wait() # Wait until the recording is finished print(“First recording stopped.”) recording = np.int16(recording * 32767) write(filename, fs, recording) print(f”First audio saved as {filename}”) thread1 = threading.Thread(target=record_audio, args=(fs, duration, filename1)) thread2 = threading.Thread(target=record_audio, args=(fs, duration, filename2)) thread1.start() thread2.start() thread1.join() thread2.join() print(“recordings complete.”)

using multiprocessing, i just replaced the classes and the result is

import sounddevice as sd from scipy.io.wavfile import write import numpy as np from multiprocessing import Process fs = 44100 duration = 5 filename1 = ‘output.wav’ filename2 = ‘second_output.wav’ def record_audio(fs, duration, filename): print(f”Recording audio to {filename}…”) recording = sd.rec(int(duration * fs), samplerate=fs, channels=2, dtype=’float64′) sd.wait() print(f”Recording stopped for {filename}.”) recording = np.int16(recording * 32767) write(filename, fs, recording) print(f”Audio saved as {filename}”) process1 = Process(target=record_audio, args=(fs, duration, filename1)) process2 = Process(target=record_audio, args=(fs, duration, filename2)) process1.start() process2.start() process1.join() process2.join() print(“recordings complete.”)

however it is not recording anything, it prints ‘recordings completed’ instantly

what am i doing wrong?

thanks

submitted by /u/qhelspil
[link] [comments]

​r/learnpython i want to record 2 audios at the same time. using multithreadind this code works fine import sounddevice as sd from scipy.io.wavfile import write import numpy as np import threading fs = 44100 duration = 5 filename1 = ‘output.wav’ filename2 = ‘second_output.wav’ def record_audio(fs, duration, filename): print(f”Recording first audio to {filename}…”) recording = sd.rec(int(duration * fs), samplerate=fs, channels=2, dtype=’float64′) sd.wait() # Wait until the recording is finished print(“First recording stopped.”) recording = np.int16(recording * 32767) write(filename, fs, recording) print(f”First audio saved as {filename}”) thread1 = threading.Thread(target=record_audio, args=(fs, duration, filename1)) thread2 = threading.Thread(target=record_audio, args=(fs, duration, filename2)) thread1.start() thread2.start() thread1.join() thread2.join() print(“recordings complete.”) using multiprocessing, i just replaced the classes and the result is import sounddevice as sd from scipy.io.wavfile import write import numpy as np from multiprocessing import Process fs = 44100 duration = 5 filename1 = ‘output.wav’ filename2 = ‘second_output.wav’ def record_audio(fs, duration, filename): print(f”Recording audio to {filename}…”) recording = sd.rec(int(duration * fs), samplerate=fs, channels=2, dtype=’float64′) sd.wait() print(f”Recording stopped for {filename}.”) recording = np.int16(recording * 32767) write(filename, fs, recording) print(f”Audio saved as {filename}”) process1 = Process(target=record_audio, args=(fs, duration, filename1)) process2 = Process(target=record_audio, args=(fs, duration, filename2)) process1.start() process2.start() process1.join() process2.join() print(“recordings complete.”) however it is not recording anything, it prints ‘recordings completed’ instantly what am i doing wrong? thanks submitted by /u/qhelspil [link] [comments] 

i want to record 2 audios at the same time.

using multithreadind this code works fine

import sounddevice as sd from scipy.io.wavfile import write import numpy as np import threading fs = 44100 duration = 5 filename1 = ‘output.wav’ filename2 = ‘second_output.wav’ def record_audio(fs, duration, filename): print(f”Recording first audio to {filename}…”) recording = sd.rec(int(duration * fs), samplerate=fs, channels=2, dtype=’float64′) sd.wait() # Wait until the recording is finished print(“First recording stopped.”) recording = np.int16(recording * 32767) write(filename, fs, recording) print(f”First audio saved as {filename}”) thread1 = threading.Thread(target=record_audio, args=(fs, duration, filename1)) thread2 = threading.Thread(target=record_audio, args=(fs, duration, filename2)) thread1.start() thread2.start() thread1.join() thread2.join() print(“recordings complete.”)

using multiprocessing, i just replaced the classes and the result is

import sounddevice as sd from scipy.io.wavfile import write import numpy as np from multiprocessing import Process fs = 44100 duration = 5 filename1 = ‘output.wav’ filename2 = ‘second_output.wav’ def record_audio(fs, duration, filename): print(f”Recording audio to {filename}…”) recording = sd.rec(int(duration * fs), samplerate=fs, channels=2, dtype=’float64′) sd.wait() print(f”Recording stopped for {filename}.”) recording = np.int16(recording * 32767) write(filename, fs, recording) print(f”Audio saved as {filename}”) process1 = Process(target=record_audio, args=(fs, duration, filename1)) process2 = Process(target=record_audio, args=(fs, duration, filename2)) process1.start() process2.start() process1.join() process2.join() print(“recordings complete.”)

however it is not recording anything, it prints ‘recordings completed’ instantly

what am i doing wrong?

thanks

submitted by /u/qhelspil
[link] [comments]  i want to record 2 audios at the same time. using multithreadind this code works fine import sounddevice as sd from scipy.io.wavfile import write import numpy as np import threading fs = 44100 duration = 5 filename1 = ‘output.wav’ filename2 = ‘second_output.wav’ def record_audio(fs, duration, filename): print(f”Recording first audio to {filename}…”) recording = sd.rec(int(duration * fs), samplerate=fs, channels=2, dtype=’float64′) sd.wait() # Wait until the recording is finished print(“First recording stopped.”) recording = np.int16(recording * 32767) write(filename, fs, recording) print(f”First audio saved as {filename}”) thread1 = threading.Thread(target=record_audio, args=(fs, duration, filename1)) thread2 = threading.Thread(target=record_audio, args=(fs, duration, filename2)) thread1.start() thread2.start() thread1.join() thread2.join() print(“recordings complete.”) using multiprocessing, i just replaced the classes and the result is import sounddevice as sd from scipy.io.wavfile import write import numpy as np from multiprocessing import Process fs = 44100 duration = 5 filename1 = ‘output.wav’ filename2 = ‘second_output.wav’ def record_audio(fs, duration, filename): print(f”Recording audio to {filename}…”) recording = sd.rec(int(duration * fs), samplerate=fs, channels=2, dtype=’float64′) sd.wait() print(f”Recording stopped for {filename}.”) recording = np.int16(recording * 32767) write(filename, fs, recording) print(f”Audio saved as {filename}”) process1 = Process(target=record_audio, args=(fs, duration, filename1)) process2 = Process(target=record_audio, args=(fs, duration, filename2)) process1.start() process2.start() process1.join() process2.join() print(“recordings complete.”) however it is not recording anything, it prints ‘recordings completed’ instantly what am i doing wrong? thanks submitted by /u/qhelspil [link] [comments]

Read more

How do I code a 40gb OneDrive File without downloading? /u/Butterlover1996 Python Education

How do I code a 40gb OneDrive File without downloading? /u/Butterlover1996 Python Education

I have a 40gb OneDrive File with 50ish csv files of data for the last 4 years (one month per csv). So I downloaded a few files, like the latest months, did my analysis and now I just have to clean up the rest and apply my analysis to a large scale. Problem is that I do not want to download the entire library. I mean there has to be a way to do python and pandas on this file without downloading the whole thing. This is the first time I am doing something like this. My old job was multiple analysis of multiple products but at least the files where small (Less than 3 gb). Now my new job is only three things to analyze but the files are huge.

submitted by /u/Butterlover1996
[link] [comments]

​r/learnpython I have a 40gb OneDrive File with 50ish csv files of data for the last 4 years (one month per csv). So I downloaded a few files, like the latest months, did my analysis and now I just have to clean up the rest and apply my analysis to a large scale. Problem is that I do not want to download the entire library. I mean there has to be a way to do python and pandas on this file without downloading the whole thing. This is the first time I am doing something like this. My old job was multiple analysis of multiple products but at least the files where small (Less than 3 gb). Now my new job is only three things to analyze but the files are huge. submitted by /u/Butterlover1996 [link] [comments] 

I have a 40gb OneDrive File with 50ish csv files of data for the last 4 years (one month per csv). So I downloaded a few files, like the latest months, did my analysis and now I just have to clean up the rest and apply my analysis to a large scale. Problem is that I do not want to download the entire library. I mean there has to be a way to do python and pandas on this file without downloading the whole thing. This is the first time I am doing something like this. My old job was multiple analysis of multiple products but at least the files where small (Less than 3 gb). Now my new job is only three things to analyze but the files are huge.

submitted by /u/Butterlover1996
[link] [comments]  I have a 40gb OneDrive File with 50ish csv files of data for the last 4 years (one month per csv). So I downloaded a few files, like the latest months, did my analysis and now I just have to clean up the rest and apply my analysis to a large scale. Problem is that I do not want to download the entire library. I mean there has to be a way to do python and pandas on this file without downloading the whole thing. This is the first time I am doing something like this. My old job was multiple analysis of multiple products but at least the files where small (Less than 3 gb). Now my new job is only three things to analyze but the files are huge. submitted by /u/Butterlover1996 [link] [comments]

Read more

How do you guys deal when you reach a mental obstacle? /u/Bulky_Slice_235 Python Education

How do you guys deal when you reach a mental obstacle? /u/Bulky_Slice_235 Python Education

Hey all!

So I have been learning to program using the book Automate the boring stuff, and it has been an amazing journey so far. I have learned things that I didn’t knew about programing (Even tho I still feel like I have to go more deep with concepts and stuff like that) and have been able to do the projects the book gives as a challenge. On the side, I was able to automate a process that used to take me a whole day, and now it takes me 30 minutes. Right now tho, I’m getting onto the frustrating projects (at least for me as a begginer) from the book and it seems I can’t find a solution to continue. I was wondering what is your go to method (as pro programmers) to moments when you feel you can’t find a solution to your problem.

submitted by /u/Bulky_Slice_235
[link] [comments]

​r/learnpython Hey all! So I have been learning to program using the book Automate the boring stuff, and it has been an amazing journey so far. I have learned things that I didn’t knew about programing (Even tho I still feel like I have to go more deep with concepts and stuff like that) and have been able to do the projects the book gives as a challenge. On the side, I was able to automate a process that used to take me a whole day, and now it takes me 30 minutes. Right now tho, I’m getting onto the frustrating projects (at least for me as a begginer) from the book and it seems I can’t find a solution to continue. I was wondering what is your go to method (as pro programmers) to moments when you feel you can’t find a solution to your problem. submitted by /u/Bulky_Slice_235 [link] [comments] 

Hey all!

So I have been learning to program using the book Automate the boring stuff, and it has been an amazing journey so far. I have learned things that I didn’t knew about programing (Even tho I still feel like I have to go more deep with concepts and stuff like that) and have been able to do the projects the book gives as a challenge. On the side, I was able to automate a process that used to take me a whole day, and now it takes me 30 minutes. Right now tho, I’m getting onto the frustrating projects (at least for me as a begginer) from the book and it seems I can’t find a solution to continue. I was wondering what is your go to method (as pro programmers) to moments when you feel you can’t find a solution to your problem.

submitted by /u/Bulky_Slice_235
[link] [comments]  Hey all! So I have been learning to program using the book Automate the boring stuff, and it has been an amazing journey so far. I have learned things that I didn’t knew about programing (Even tho I still feel like I have to go more deep with concepts and stuff like that) and have been able to do the projects the book gives as a challenge. On the side, I was able to automate a process that used to take me a whole day, and now it takes me 30 minutes. Right now tho, I’m getting onto the frustrating projects (at least for me as a begginer) from the book and it seems I can’t find a solution to continue. I was wondering what is your go to method (as pro programmers) to moments when you feel you can’t find a solution to your problem. submitted by /u/Bulky_Slice_235 [link] [comments]

Read more

How can I improve the code in this Python project? /u/GrizzyLizz Python Education

How can I improve the code in this Python project? /u/GrizzyLizz Python Education

Link: https://gitlab.com/__muditj__/gmail-cli-automation-tool

So I was given an assignment task for hiring and I ended up rushing through it a little so I didnt do so well. The task was: Given a rules.json file which defines certain filters for emails based on different fields like From, Subject, Content etc, filter out the emails which obey the rules and apply the specified actions on them. This is a CLI application where I make use of OAuth2 to authenticate with Google’s Gmail API

I am aware that there are excessive print statements and I dont have any unit tests added but apart from this, in what other ways can I improve the codebase? In particular, I want to know what would be the ideal way to package this application. This was meant to be a CLI application which should be runnable as a script so I have two particular Python files with a “if __name__ == “__main__” block inside them. One is to authenticate with Google OAuth and get the access and refresh token and the other is to run the main part of the application which does the filtering of the emails and applies the specified actions.

submitted by /u/GrizzyLizz
[link] [comments]

​r/learnpython Link: https://gitlab.com/__muditj__/gmail-cli-automation-tool So I was given an assignment task for hiring and I ended up rushing through it a little so I didnt do so well. The task was: Given a rules.json file which defines certain filters for emails based on different fields like From, Subject, Content etc, filter out the emails which obey the rules and apply the specified actions on them. This is a CLI application where I make use of OAuth2 to authenticate with Google’s Gmail API I am aware that there are excessive print statements and I dont have any unit tests added but apart from this, in what other ways can I improve the codebase? In particular, I want to know what would be the ideal way to package this application. This was meant to be a CLI application which should be runnable as a script so I have two particular Python files with a “if __name__ == “__main__” block inside them. One is to authenticate with Google OAuth and get the access and refresh token and the other is to run the main part of the application which does the filtering of the emails and applies the specified actions. submitted by /u/GrizzyLizz [link] [comments] 

Link: https://gitlab.com/__muditj__/gmail-cli-automation-tool

So I was given an assignment task for hiring and I ended up rushing through it a little so I didnt do so well. The task was: Given a rules.json file which defines certain filters for emails based on different fields like From, Subject, Content etc, filter out the emails which obey the rules and apply the specified actions on them. This is a CLI application where I make use of OAuth2 to authenticate with Google’s Gmail API

I am aware that there are excessive print statements and I dont have any unit tests added but apart from this, in what other ways can I improve the codebase? In particular, I want to know what would be the ideal way to package this application. This was meant to be a CLI application which should be runnable as a script so I have two particular Python files with a “if __name__ == “__main__” block inside them. One is to authenticate with Google OAuth and get the access and refresh token and the other is to run the main part of the application which does the filtering of the emails and applies the specified actions.

submitted by /u/GrizzyLizz
[link] [comments]  Link: https://gitlab.com/__muditj__/gmail-cli-automation-tool So I was given an assignment task for hiring and I ended up rushing through it a little so I didnt do so well. The task was: Given a rules.json file which defines certain filters for emails based on different fields like From, Subject, Content etc, filter out the emails which obey the rules and apply the specified actions on them. This is a CLI application where I make use of OAuth2 to authenticate with Google’s Gmail API I am aware that there are excessive print statements and I dont have any unit tests added but apart from this, in what other ways can I improve the codebase? In particular, I want to know what would be the ideal way to package this application. This was meant to be a CLI application which should be runnable as a script so I have two particular Python files with a “if __name__ == “__main__” block inside them. One is to authenticate with Google OAuth and get the access and refresh token and the other is to run the main part of the application which does the filtering of the emails and applies the specified actions. submitted by /u/GrizzyLizz [link] [comments]

Read more

Python library documentation /u/Classic_essays Python Education

Python library documentation /u/Classic_essays Python Education

Hello guys.

I’m working on an opensource library and I need to start documenting it. I will use Readthedocs for hosting.

However, I’m caught between using mkdocs and sphnix. Any advice on this would be greatly appreciated.

Thanks

submitted by /u/Classic_essays
[link] [comments]

​r/learnpython Hello guys. I’m working on an opensource library and I need to start documenting it. I will use Readthedocs for hosting. However, I’m caught between using mkdocs and sphnix. Any advice on this would be greatly appreciated. Thanks submitted by /u/Classic_essays [link] [comments] 

Hello guys.

I’m working on an opensource library and I need to start documenting it. I will use Readthedocs for hosting.

However, I’m caught between using mkdocs and sphnix. Any advice on this would be greatly appreciated.

Thanks

submitted by /u/Classic_essays
[link] [comments]  Hello guys. I’m working on an opensource library and I need to start documenting it. I will use Readthedocs for hosting. However, I’m caught between using mkdocs and sphnix. Any advice on this would be greatly appreciated. Thanks submitted by /u/Classic_essays [link] [comments]

Read more