Accessing Django Model in program? /u/Rapid1898 Python Education

Accessing Django Model in program? /u/Rapid1898 Python Education

Hello – i have created a Model in the models.py and now i wanted to access the model with another seperate program which is called temp.py for testing

This is my models.py

from django.db import models class Queue(models.Model): timestamp = models.CharField(max_length = 50, blank = True) firstName = models.CharField(max_length = 200, blank = True)

And this is my temp.py

“` import django import os os.environ.setdefault(“DJANGO_SETTINGS_MODULE”, “gpt.settings”) django.setup() from .models import Queue

worker = Queue.objects.all() print(worker) “`

But when i run the temp.py program i get this error

(Django) C:DEVFiverrORDERcolli239gptgpp>python temp.py Traceback (most recent call last): File “C:DEVFiverrORDERcolli239gptgpptemp.py”, line 1, in <module> from .models import Queue ImportError: attempted relative import with no known parent package

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

​r/learnpython Hello – i have created a Model in the models.py and now i wanted to access the model with another seperate program which is called temp.py for testing This is my models.py from django.db import models class Queue(models.Model): timestamp = models.CharField(max_length = 50, blank = True) firstName = models.CharField(max_length = 200, blank = True) And this is my temp.py “` import django import os os.environ.setdefault(“DJANGO_SETTINGS_MODULE”, “gpt.settings”) django.setup() from .models import Queue worker = Queue.objects.all() print(worker) “` But when i run the temp.py program i get this error (Django) C:DEVFiverrORDERcolli239gptgpp>python temp.py Traceback (most recent call last): File “C:DEVFiverrORDERcolli239gptgpptemp.py”, line 1, in <module> from .models import Queue ImportError: attempted relative import with no known parent package submitted by /u/Rapid1898 [link] [comments] 

Hello – i have created a Model in the models.py and now i wanted to access the model with another seperate program which is called temp.py for testing

This is my models.py

from django.db import models class Queue(models.Model): timestamp = models.CharField(max_length = 50, blank = True) firstName = models.CharField(max_length = 200, blank = True)

And this is my temp.py

“` import django import os os.environ.setdefault(“DJANGO_SETTINGS_MODULE”, “gpt.settings”) django.setup() from .models import Queue

worker = Queue.objects.all() print(worker) “`

But when i run the temp.py program i get this error

(Django) C:DEVFiverrORDERcolli239gptgpp>python temp.py Traceback (most recent call last): File “C:DEVFiverrORDERcolli239gptgpptemp.py”, line 1, in <module> from .models import Queue ImportError: attempted relative import with no known parent package

submitted by /u/Rapid1898
[link] [comments]  Hello – i have created a Model in the models.py and now i wanted to access the model with another seperate program which is called temp.py for testing This is my models.py from django.db import models class Queue(models.Model): timestamp = models.CharField(max_length = 50, blank = True) firstName = models.CharField(max_length = 200, blank = True) And this is my temp.py “` import django import os os.environ.setdefault(“DJANGO_SETTINGS_MODULE”, “gpt.settings”) django.setup() from .models import Queue worker = Queue.objects.all() print(worker) “` But when i run the temp.py program i get this error (Django) C:DEVFiverrORDERcolli239gptgpp>python temp.py Traceback (most recent call last): File “C:DEVFiverrORDERcolli239gptgpptemp.py”, line 1, in <module> from .models import Queue ImportError: attempted relative import with no known parent package submitted by /u/Rapid1898 [link] [comments]

Read more

Is the University of Helsinki MOOC Python course exam free? /u/JebusdeMazaret Python Education

Is the University of Helsinki MOOC Python course exam free? /u/JebusdeMazaret Python Education

I just completed the first part, and I was thinking about to get the certificate, so yeah, Is there a price for the exam?

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

​r/learnpython I just completed the first part, and I was thinking about to get the certificate, so yeah, Is there a price for the exam? submitted by /u/JebusdeMazaret [link] [comments] 

I just completed the first part, and I was thinking about to get the certificate, so yeah, Is there a price for the exam?

submitted by /u/JebusdeMazaret
[link] [comments]  I just completed the first part, and I was thinking about to get the certificate, so yeah, Is there a price for the exam? submitted by /u/JebusdeMazaret [link] [comments]

Read more

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