my code runs forever, unless i restart session /u/qhelspil Python Education

my code runs forever, unless i restart session /u/qhelspil Python Education

when i restart session, my code runs hte amoun tof time i specified, its like that for couple of times, until it keeps runnin forever without stopping.

this is the source of my code, i jusst made little changes ( adding path)

this snippet sometimes runs 3 seconds, sometimes forever

RECORD = “”” const sleep = time => new Promise(resolve => setTimeout(resolve, time)) const b2text = blob => new Promise(resolve => { const reader = new FileReader() reader.onloadend = e => resolve(e.srcElement.result) reader.readAsDataURL(blob) }) var record = time => new Promise(async resolve => { stream = await navigator.mediaDevices.getUserMedia({ audio: true }) recorder = new MediaRecorder(stream) chunks = [] recorder.ondataavailable = e => chunks.push(e.data) recorder.start() await sleep(time) recorder.onstop = async ()=>{ blob = new Blob(chunks) text = await b2text(blob) resolve(text) } recorder.stop() }) “”” def record_audio(sec,path): display(Javascript(RECORD)) s = output.eval_js(‘record(%d)’ % (sec*1000)) b = b64decode(s.split(‘,’)[1]) audio = AudioSegment.from_file(BytesIO(b)) audio.export(path, format=’wav’) return audio record_audio(3,’output1.wav’)

this snippet runs forever, idk why

import threading thread1 = threading.Thread(target=record_audio, args=([3,’output2.wav’])) thread2 = threading.Thread(target=record_audio, args=([3,’output3.wav’])) thread1.start() thread2.start() thread1.join() thread2.join() print(“recordings complete.”)

why is that?

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

​r/learnpython when i restart session, my code runs hte amoun tof time i specified, its like that for couple of times, until it keeps runnin forever without stopping. this is the source of my code, i jusst made little changes ( adding path) this snippet sometimes runs 3 seconds, sometimes forever RECORD = “”” const sleep = time => new Promise(resolve => setTimeout(resolve, time)) const b2text = blob => new Promise(resolve => { const reader = new FileReader() reader.onloadend = e => resolve(e.srcElement.result) reader.readAsDataURL(blob) }) var record = time => new Promise(async resolve => { stream = await navigator.mediaDevices.getUserMedia({ audio: true }) recorder = new MediaRecorder(stream) chunks = [] recorder.ondataavailable = e => chunks.push(e.data) recorder.start() await sleep(time) recorder.onstop = async ()=>{ blob = new Blob(chunks) text = await b2text(blob) resolve(text) } recorder.stop() }) “”” def record_audio(sec,path): display(Javascript(RECORD)) s = output.eval_js(‘record(%d)’ % (sec*1000)) b = b64decode(s.split(‘,’)[1]) audio = AudioSegment.from_file(BytesIO(b)) audio.export(path, format=’wav’) return audio record_audio(3,’output1.wav’) this snippet runs forever, idk why import threading thread1 = threading.Thread(target=record_audio, args=([3,’output2.wav’])) thread2 = threading.Thread(target=record_audio, args=([3,’output3.wav’])) thread1.start() thread2.start() thread1.join() thread2.join() print(“recordings complete.”) why is that? submitted by /u/qhelspil [link] [comments] 

when i restart session, my code runs hte amoun tof time i specified, its like that for couple of times, until it keeps runnin forever without stopping.

this is the source of my code, i jusst made little changes ( adding path)

this snippet sometimes runs 3 seconds, sometimes forever

RECORD = “”” const sleep = time => new Promise(resolve => setTimeout(resolve, time)) const b2text = blob => new Promise(resolve => { const reader = new FileReader() reader.onloadend = e => resolve(e.srcElement.result) reader.readAsDataURL(blob) }) var record = time => new Promise(async resolve => { stream = await navigator.mediaDevices.getUserMedia({ audio: true }) recorder = new MediaRecorder(stream) chunks = [] recorder.ondataavailable = e => chunks.push(e.data) recorder.start() await sleep(time) recorder.onstop = async ()=>{ blob = new Blob(chunks) text = await b2text(blob) resolve(text) } recorder.stop() }) “”” def record_audio(sec,path): display(Javascript(RECORD)) s = output.eval_js(‘record(%d)’ % (sec*1000)) b = b64decode(s.split(‘,’)[1]) audio = AudioSegment.from_file(BytesIO(b)) audio.export(path, format=’wav’) return audio record_audio(3,’output1.wav’)

this snippet runs forever, idk why

import threading thread1 = threading.Thread(target=record_audio, args=([3,’output2.wav’])) thread2 = threading.Thread(target=record_audio, args=([3,’output3.wav’])) thread1.start() thread2.start() thread1.join() thread2.join() print(“recordings complete.”)

why is that?

submitted by /u/qhelspil
[link] [comments]  when i restart session, my code runs hte amoun tof time i specified, its like that for couple of times, until it keeps runnin forever without stopping. this is the source of my code, i jusst made little changes ( adding path) this snippet sometimes runs 3 seconds, sometimes forever RECORD = “”” const sleep = time => new Promise(resolve => setTimeout(resolve, time)) const b2text = blob => new Promise(resolve => { const reader = new FileReader() reader.onloadend = e => resolve(e.srcElement.result) reader.readAsDataURL(blob) }) var record = time => new Promise(async resolve => { stream = await navigator.mediaDevices.getUserMedia({ audio: true }) recorder = new MediaRecorder(stream) chunks = [] recorder.ondataavailable = e => chunks.push(e.data) recorder.start() await sleep(time) recorder.onstop = async ()=>{ blob = new Blob(chunks) text = await b2text(blob) resolve(text) } recorder.stop() }) “”” def record_audio(sec,path): display(Javascript(RECORD)) s = output.eval_js(‘record(%d)’ % (sec*1000)) b = b64decode(s.split(‘,’)[1]) audio = AudioSegment.from_file(BytesIO(b)) audio.export(path, format=’wav’) return audio record_audio(3,’output1.wav’) this snippet runs forever, idk why import threading thread1 = threading.Thread(target=record_audio, args=([3,’output2.wav’])) thread2 = threading.Thread(target=record_audio, args=([3,’output3.wav’])) thread1.start() thread2.start() thread1.join() thread2.join() print(“recordings complete.”) why is that? submitted by /u/qhelspil [link] [comments]

Read more

Matplotlib – Secondary axis lacks anti-aliasing? /u/Thunderflower58 Python Education

Matplotlib – Secondary axis lacks anti-aliasing? /u/Thunderflower58 Python Education

Hi everybody, I didn’t find anything on this problem while searching the web. When adding a second x-axis to my plots, the secondary axis seems to lack anti-aliasing or sth (it just looks weirdly bold and pixelated). The secondary axis is added with ax.secondary_xaxis. I plan to export these as .svg and depending on the scaling it just looks awful (they also look bad as .png). The other side of the x-axis looks fine.

Does anyone have an idea as to what could be causing this? I am using Matplotlib 3.4.3 and Python 3.9.7.

(So far I haven’t been able to reproduce this behaviour in a MWE and otherwise it would be a hole load of code and data)

Edit: It seems that my image wasn’t uploaded with the post, trying to fix it…

Image: https://imgur.com/a/aadLbpO

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

​r/learnpython Hi everybody, I didn’t find anything on this problem while searching the web. When adding a second x-axis to my plots, the secondary axis seems to lack anti-aliasing or sth (it just looks weirdly bold and pixelated). The secondary axis is added with ax.secondary_xaxis. I plan to export these as .svg and depending on the scaling it just looks awful (they also look bad as .png). The other side of the x-axis looks fine. Does anyone have an idea as to what could be causing this? I am using Matplotlib 3.4.3 and Python 3.9.7. (So far I haven’t been able to reproduce this behaviour in a MWE and otherwise it would be a hole load of code and data) Edit: It seems that my image wasn’t uploaded with the post, trying to fix it… Image: https://imgur.com/a/aadLbpO submitted by /u/Thunderflower58 [link] [comments] 

Hi everybody, I didn’t find anything on this problem while searching the web. When adding a second x-axis to my plots, the secondary axis seems to lack anti-aliasing or sth (it just looks weirdly bold and pixelated). The secondary axis is added with ax.secondary_xaxis. I plan to export these as .svg and depending on the scaling it just looks awful (they also look bad as .png). The other side of the x-axis looks fine.

Does anyone have an idea as to what could be causing this? I am using Matplotlib 3.4.3 and Python 3.9.7.

(So far I haven’t been able to reproduce this behaviour in a MWE and otherwise it would be a hole load of code and data)

Edit: It seems that my image wasn’t uploaded with the post, trying to fix it…

Image: https://imgur.com/a/aadLbpO

submitted by /u/Thunderflower58
[link] [comments]  Hi everybody, I didn’t find anything on this problem while searching the web. When adding a second x-axis to my plots, the secondary axis seems to lack anti-aliasing or sth (it just looks weirdly bold and pixelated). The secondary axis is added with ax.secondary_xaxis. I plan to export these as .svg and depending on the scaling it just looks awful (they also look bad as .png). The other side of the x-axis looks fine. Does anyone have an idea as to what could be causing this? I am using Matplotlib 3.4.3 and Python 3.9.7. (So far I haven’t been able to reproduce this behaviour in a MWE and otherwise it would be a hole load of code and data) Edit: It seems that my image wasn’t uploaded with the post, trying to fix it… Image: https://imgur.com/a/aadLbpO submitted by /u/Thunderflower58 [link] [comments]

Read more

Is there a way to tell if a package I downloaded connects to the internet when I’m using it? /u/OutRagousGameR Python Education

Is there a way to tell if a package I downloaded connects to the internet when I’m using it? /u/OutRagousGameR Python Education

I’m looking to download a personal, local LLM.

Plus, if I’m going to integrate personal files with an open source LLM (like Llama or Private GPT), I want to make sure that my data/prompts aren’t being delivered back to its developers (like Meta).

I’m new to python, self taught. And I’m using a Mac

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

​r/learnpython I’m looking to download a personal, local LLM. Plus, if I’m going to integrate personal files with an open source LLM (like Llama or Private GPT), I want to make sure that my data/prompts aren’t being delivered back to its developers (like Meta). I’m new to python, self taught. And I’m using a Mac submitted by /u/OutRagousGameR [link] [comments] 

I’m looking to download a personal, local LLM.

Plus, if I’m going to integrate personal files with an open source LLM (like Llama or Private GPT), I want to make sure that my data/prompts aren’t being delivered back to its developers (like Meta).

I’m new to python, self taught. And I’m using a Mac

submitted by /u/OutRagousGameR
[link] [comments]  I’m looking to download a personal, local LLM. Plus, if I’m going to integrate personal files with an open source LLM (like Llama or Private GPT), I want to make sure that my data/prompts aren’t being delivered back to its developers (like Meta). I’m new to python, self taught. And I’m using a Mac submitted by /u/OutRagousGameR [link] [comments]

Read more

Struggling to understand how to structure Classes and methods /u/redrabbit1984 Python Education

Struggling to understand how to structure Classes and methods /u/redrabbit1984 Python Education

Hi,

I’ve been using Python for years but for simple scripts and IT related things. I’m starting a new project to do with AWS.

Data:

AWS has Regions (us-east-1, eu-west-3, etc) Regions have EC-2 instances

So my thought is:

Class Instance: xxx Class Region: xxx

My question is, let’s say the script starts and I want to output all the instances. How would that work?

Would Region have a method called: def get_instances(self.region_id) in which it would get all the regions, or would it go to Instance?

Would be great to get an idea of how you’d structure this.

The script will:

List all regions List all instances in the regions and their state Allow the user to stop the instance or start it

And other things after that

Thanks

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

​r/learnpython Hi, I’ve been using Python for years but for simple scripts and IT related things. I’m starting a new project to do with AWS. ​ Data: AWS has Regions (us-east-1, eu-west-3, etc) Regions have EC-2 instances ​ So my thought is: Class Instance: xxx Class Region: xxx My question is, let’s say the script starts and I want to output all the instances. How would that work? Would Region have a method called: def get_instances(self.region_id) in which it would get all the regions, or would it go to Instance? Would be great to get an idea of how you’d structure this. The script will: List all regions List all instances in the regions and their state Allow the user to stop the instance or start it And other things after that Thanks ​ submitted by /u/redrabbit1984 [link] [comments] 

Hi,

I’ve been using Python for years but for simple scripts and IT related things. I’m starting a new project to do with AWS.

Data:

AWS has Regions (us-east-1, eu-west-3, etc) Regions have EC-2 instances

So my thought is:

Class Instance: xxx Class Region: xxx

My question is, let’s say the script starts and I want to output all the instances. How would that work?

Would Region have a method called: def get_instances(self.region_id) in which it would get all the regions, or would it go to Instance?

Would be great to get an idea of how you’d structure this.

The script will:

List all regions List all instances in the regions and their state Allow the user to stop the instance or start it

And other things after that

Thanks

submitted by /u/redrabbit1984
[link] [comments]  Hi, I’ve been using Python for years but for simple scripts and IT related things. I’m starting a new project to do with AWS. ​ Data: AWS has Regions (us-east-1, eu-west-3, etc) Regions have EC-2 instances ​ So my thought is: Class Instance: xxx Class Region: xxx My question is, let’s say the script starts and I want to output all the instances. How would that work? Would Region have a method called: def get_instances(self.region_id) in which it would get all the regions, or would it go to Instance? Would be great to get an idea of how you’d structure this. The script will: List all regions List all instances in the regions and their state Allow the user to stop the instance or start it And other things after that Thanks ​ submitted by /u/redrabbit1984 [link] [comments]

Read more

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

Best language to build 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

Python execution problem from cpp shared object /u/Rough_Metal_9999 Python Education

Python execution problem from cpp shared object /u/Rough_Metal_9999 Python Education

I have a python program that loads a .so file generated with cpp code in the code i expose a function that executes a simple hello world program

everything works fine when i run cpp program it executes and prints hello world

when i make so file , and call the same function from .py file and run the py file it gives me error of

<code>

free(): invalid pointer
zsh: IOT instruction (core dumped) python3 main.py

</code>

i use cout statement to find out the problem occur while initilising python Py_Initialize(); in this method

itry to execute the function call with another thread same error occour

Why this happend and how i solve it

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

​r/learnpython I have a python program that loads a .so file generated with cpp code in the code i expose a function that executes a simple hello world program everything works fine when i run cpp program it executes and prints hello world when i make so file , and call the same function from .py file and run the py file it gives me error of <code> free(): invalid pointer zsh: IOT instruction (core dumped) python3 main.py </code> i use cout statement to find out the problem occur while initilising python Py_Initialize(); in this method itry to execute the function call with another thread same error occour ​ Why this happend and how i solve it submitted by /u/Rough_Metal_9999 [link] [comments] 

I have a python program that loads a .so file generated with cpp code in the code i expose a function that executes a simple hello world program

everything works fine when i run cpp program it executes and prints hello world

when i make so file , and call the same function from .py file and run the py file it gives me error of

<code>

free(): invalid pointer
zsh: IOT instruction (core dumped) python3 main.py

</code>

i use cout statement to find out the problem occur while initilising python Py_Initialize(); in this method

itry to execute the function call with another thread same error occour

Why this happend and how i solve it

submitted by /u/Rough_Metal_9999
[link] [comments]  I have a python program that loads a .so file generated with cpp code in the code i expose a function that executes a simple hello world program everything works fine when i run cpp program it executes and prints hello world when i make so file , and call the same function from .py file and run the py file it gives me error of <code> free(): invalid pointer zsh: IOT instruction (core dumped) python3 main.py </code> i use cout statement to find out the problem occur while initilising python Py_Initialize(); in this method itry to execute the function call with another thread same error occour ​ Why this happend and how i solve it submitted by /u/Rough_Metal_9999 [link] [comments]

Read more

I’m struggling with learning python /u/Affectionate_Play180 Python Education

I’m struggling with learning python /u/Affectionate_Play180 Python Education

So I have been taking this python class at WGU and it’s killing me. The way the course is set up is very odd and incoherent IMO. I feel like I need a deep dive on the basics. Are there any books or courses (preferably Udemy because I get them for free) that would help a beginner? Any advice or suggestions would be greatly appreciated.

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

​r/learnpython So I have been taking this python class at WGU and it’s killing me. The way the course is set up is very odd and incoherent IMO. I feel like I need a deep dive on the basics. Are there any books or courses (preferably Udemy because I get them for free) that would help a beginner? Any advice or suggestions would be greatly appreciated. submitted by /u/Affectionate_Play180 [link] [comments] 

So I have been taking this python class at WGU and it’s killing me. The way the course is set up is very odd and incoherent IMO. I feel like I need a deep dive on the basics. Are there any books or courses (preferably Udemy because I get them for free) that would help a beginner? Any advice or suggestions would be greatly appreciated.

submitted by /u/Affectionate_Play180
[link] [comments]  So I have been taking this python class at WGU and it’s killing me. The way the course is set up is very odd and incoherent IMO. I feel like I need a deep dive on the basics. Are there any books or courses (preferably Udemy because I get them for free) that would help a beginner? Any advice or suggestions would be greatly appreciated. submitted by /u/Affectionate_Play180 [link] [comments]

Read more

Can you filter pandas dataframes by Day/Month date without year? Writing a generalised function for between date that is year agnostic is proving difficult. /u/Statnamara Python Education

Can you filter pandas dataframes by Day/Month date without year? Writing a generalised function for between date that is year agnostic is proving difficult. /u/Statnamara Python Education

Ths issue stems from using year agnostic dates. If I want to return dates between June 15th – Sep 15th for every year it seems I need to manually write

df[“date_col”].dt.month.eq(6) & df[“date_col”].dt.day.ge(15) df[“date_col”].dt.month.between(7,8) df[“date_col”].dt.month.eq(9) & df[“date_col”].dt.day.le(15)

This doesn’t generalise well. Writing a function that takes a min and max date has a lot of different edge cases, i.e. dates are in the same month, dates are in consecutive months, dates cross a new year, etc.

A big part of the problem is that pd.to_datetime(“1506”, format = “%d%m”) returns Timestamp(‘1900-06-15 00:00:00’) and is therefore very much NOT year agnostic.

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

​r/learnpython Ths issue stems from using year agnostic dates. If I want to return dates between June 15th – Sep 15th for every year it seems I need to manually write df[“date_col”].dt.month.eq(6) & df[“date_col”].dt.day.ge(15) df[“date_col”].dt.month.between(7,8) df[“date_col”].dt.month.eq(9) & df[“date_col”].dt.day.le(15) This doesn’t generalise well. Writing a function that takes a min and max date has a lot of different edge cases, i.e. dates are in the same month, dates are in consecutive months, dates cross a new year, etc. A big part of the problem is that pd.to_datetime(“1506”, format = “%d%m”) returns Timestamp(‘1900-06-15 00:00:00’) and is therefore very much NOT year agnostic. submitted by /u/Statnamara [link] [comments] 

Ths issue stems from using year agnostic dates. If I want to return dates between June 15th – Sep 15th for every year it seems I need to manually write

df[“date_col”].dt.month.eq(6) & df[“date_col”].dt.day.ge(15) df[“date_col”].dt.month.between(7,8) df[“date_col”].dt.month.eq(9) & df[“date_col”].dt.day.le(15)

This doesn’t generalise well. Writing a function that takes a min and max date has a lot of different edge cases, i.e. dates are in the same month, dates are in consecutive months, dates cross a new year, etc.

A big part of the problem is that pd.to_datetime(“1506”, format = “%d%m”) returns Timestamp(‘1900-06-15 00:00:00’) and is therefore very much NOT year agnostic.

submitted by /u/Statnamara
[link] [comments]  Ths issue stems from using year agnostic dates. If I want to return dates between June 15th – Sep 15th for every year it seems I need to manually write df[“date_col”].dt.month.eq(6) & df[“date_col”].dt.day.ge(15) df[“date_col”].dt.month.between(7,8) df[“date_col”].dt.month.eq(9) & df[“date_col”].dt.day.le(15) This doesn’t generalise well. Writing a function that takes a min and max date has a lot of different edge cases, i.e. dates are in the same month, dates are in consecutive months, dates cross a new year, etc. A big part of the problem is that pd.to_datetime(“1506”, format = “%d%m”) returns Timestamp(‘1900-06-15 00:00:00’) and is therefore very much NOT year agnostic. submitted by /u/Statnamara [link] [comments]

Read more