check if “text” in variable something wrong. /u/cctl01 Python Education

check if “text” in variable something wrong. /u/cctl01 Python Education

I’m taking my first babysteps in python coding.

With the code below I’m using the function check to see if in the last hour a post is made in r/GameDeals and if the title contains the word ‘free’ or ‘0.00’ the information of that post is send to the send function which pushes a notification.

However the output below shows an entry where neither ‘0.00’ or ‘free’ is in the title. What am I missing?

def send(NAME,APPURL): conn = http.client.HTTPSConnection("api.pushover.net:443") conn.request("POST", "/1/messages.json", urllib.parse.urlencode({ "token": APP_TOKEN, "user": USER_KEY, "message": APPURL, "title": NAME, }), { "Content-type": "application/x-www-form-urlencoded" }) conn.getresponse() def check(): gratis=[] reddit = praw.Reddit( client_id=CLIENTID, client_secret=CLIENTSECRET, user_agent="linux:freeapp:0.1 (by u/cctl01)", ) print(reddit.read_only) current_time = time.time() one_hour_ago = current_time - 3600 #free game for submission in reddit.subreddit("GameDeals").new(limit=10): if submission.created_utc >= one_hour_ago: if 'free' or '0.00' in submission.title.lower(): gratis.append(submission) for grati in gratis: print("gamedeals "+grati.title) send(grati.title,grati.url) 

OUTPUT:

(venv) /home/python # python /home/python/notification.py True gamedeals [Fanatical] Winter Sale 2024 - Elden Ring (46% off), God of War Ragnarök (25% off), HELLDIVERS 2 (25% off) & more | Rotating flash deals, bonus game or coupon for spending $15USD/$21CAD/€15EU/£15GBP 

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

​r/learnpython I’m taking my first babysteps in python coding. With the code below I’m using the function check to see if in the last hour a post is made in r/GameDeals and if the title contains the word ‘free’ or ‘0.00’ the information of that post is send to the send function which pushes a notification. However the output below shows an entry where neither ‘0.00’ or ‘free’ is in the title. What am I missing? def send(NAME,APPURL): conn = http.client.HTTPSConnection(“api.pushover.net:443”) conn.request(“POST”, “/1/messages.json”, urllib.parse.urlencode({ “token”: APP_TOKEN, “user”: USER_KEY, “message”: APPURL, “title”: NAME, }), { “Content-type”: “application/x-www-form-urlencoded” }) conn.getresponse() def check(): gratis=[] reddit = praw.Reddit( client_id=CLIENTID, client_secret=CLIENTSECRET, user_agent=”linux:freeapp:0.1 (by u/cctl01)”, ) print(reddit.read_only) current_time = time.time() one_hour_ago = current_time – 3600 #free game for submission in reddit.subreddit(“GameDeals”).new(limit=10): if submission.created_utc >= one_hour_ago: if ‘free’ or ‘0.00’ in submission.title.lower(): gratis.append(submission) for grati in gratis: print(“gamedeals “+grati.title) send(grati.title,grati.url) OUTPUT: (venv) /home/python # python /home/python/notification.py True gamedeals [Fanatical] Winter Sale 2024 – Elden Ring (46% off), God of War Ragnarök (25% off), HELLDIVERS 2 (25% off) & more | Rotating flash deals, bonus game or coupon for spending $15USD/$21CAD/€15EU/£15GBP submitted by /u/cctl01 [link] [comments] 

I’m taking my first babysteps in python coding.

With the code below I’m using the function check to see if in the last hour a post is made in r/GameDeals and if the title contains the word ‘free’ or ‘0.00’ the information of that post is send to the send function which pushes a notification.

However the output below shows an entry where neither ‘0.00’ or ‘free’ is in the title. What am I missing?

def send(NAME,APPURL): conn = http.client.HTTPSConnection("api.pushover.net:443") conn.request("POST", "/1/messages.json", urllib.parse.urlencode({ "token": APP_TOKEN, "user": USER_KEY, "message": APPURL, "title": NAME, }), { "Content-type": "application/x-www-form-urlencoded" }) conn.getresponse() def check(): gratis=[] reddit = praw.Reddit( client_id=CLIENTID, client_secret=CLIENTSECRET, user_agent="linux:freeapp:0.1 (by u/cctl01)", ) print(reddit.read_only) current_time = time.time() one_hour_ago = current_time - 3600 #free game for submission in reddit.subreddit("GameDeals").new(limit=10): if submission.created_utc >= one_hour_ago: if 'free' or '0.00' in submission.title.lower(): gratis.append(submission) for grati in gratis: print("gamedeals "+grati.title) send(grati.title,grati.url) 

OUTPUT:

(venv) /home/python # python /home/python/notification.py True gamedeals [Fanatical] Winter Sale 2024 - Elden Ring (46% off), God of War Ragnarök (25% off), HELLDIVERS 2 (25% off) & more | Rotating flash deals, bonus game or coupon for spending $15USD/$21CAD/€15EU/£15GBP 

submitted by /u/cctl01
[link] [comments]  I’m taking my first babysteps in python coding. With the code below I’m using the function check to see if in the last hour a post is made in r/GameDeals and if the title contains the word ‘free’ or ‘0.00’ the information of that post is send to the send function which pushes a notification. However the output below shows an entry where neither ‘0.00’ or ‘free’ is in the title. What am I missing? def send(NAME,APPURL): conn = http.client.HTTPSConnection(“api.pushover.net:443”) conn.request(“POST”, “/1/messages.json”, urllib.parse.urlencode({ “token”: APP_TOKEN, “user”: USER_KEY, “message”: APPURL, “title”: NAME, }), { “Content-type”: “application/x-www-form-urlencoded” }) conn.getresponse() def check(): gratis=[] reddit = praw.Reddit( client_id=CLIENTID, client_secret=CLIENTSECRET, user_agent=”linux:freeapp:0.1 (by u/cctl01)”, ) print(reddit.read_only) current_time = time.time() one_hour_ago = current_time – 3600 #free game for submission in reddit.subreddit(“GameDeals”).new(limit=10): if submission.created_utc >= one_hour_ago: if ‘free’ or ‘0.00’ in submission.title.lower(): gratis.append(submission) for grati in gratis: print(“gamedeals “+grati.title) send(grati.title,grati.url) OUTPUT: (venv) /home/python # python /home/python/notification.py True gamedeals [Fanatical] Winter Sale 2024 – Elden Ring (46% off), God of War Ragnarök (25% off), HELLDIVERS 2 (25% off) & more | Rotating flash deals, bonus game or coupon for spending $15USD/$21CAD/€15EU/£15GBP submitted by /u/cctl01 [link] [comments]

Read more

Why do I need Anaconda if I can install LangChain, Pandas, and everything else with pip? /u/umen Python Education

Why do I need Anaconda if I can install LangChain, Pandas, and everything else with pip? /u/umen Python Education

Hello everyone,

I’ve recently started working with Generative AI and am using LangChain, Pandas, and FAISS.

The previous data scientist (I’m not a data scientist; I’m a developer) installed Anaconda and used these libraries. From what I see, if I can simply install and use these libraries with pip, why would I need Anaconda?

To me, it seems like Anaconda adds an extra layer of complexity. Can someone please explain the benefits of using Anaconda?

Thanks!

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

​r/learnpython Hello everyone, I’ve recently started working with Generative AI and am using LangChain, Pandas, and FAISS. The previous data scientist (I’m not a data scientist; I’m a developer) installed Anaconda and used these libraries. From what I see, if I can simply install and use these libraries with pip, why would I need Anaconda? To me, it seems like Anaconda adds an extra layer of complexity. Can someone please explain the benefits of using Anaconda? Thanks! submitted by /u/umen [link] [comments] 

Hello everyone,

I’ve recently started working with Generative AI and am using LangChain, Pandas, and FAISS.

The previous data scientist (I’m not a data scientist; I’m a developer) installed Anaconda and used these libraries. From what I see, if I can simply install and use these libraries with pip, why would I need Anaconda?

To me, it seems like Anaconda adds an extra layer of complexity. Can someone please explain the benefits of using Anaconda?

Thanks!

submitted by /u/umen
[link] [comments]  Hello everyone, I’ve recently started working with Generative AI and am using LangChain, Pandas, and FAISS. The previous data scientist (I’m not a data scientist; I’m a developer) installed Anaconda and used these libraries. From what I see, if I can simply install and use these libraries with pip, why would I need Anaconda? To me, it seems like Anaconda adds an extra layer of complexity. Can someone please explain the benefits of using Anaconda? Thanks! submitted by /u/umen [link] [comments]

Read more

Created this Py+MySQL program for my High School Project. Need Help & Suggestions as a beginner. /u/DiligentBank7831 Python Education

Created this Py+MySQL program for my High School Project. Need Help & Suggestions as a beginner. /u/DiligentBank7831 Python Education

idk much about programming, learning. I just did this project and needed suggestions for improvements as well as recommendations on what topics should i focus on & learn. I’d be grateful for your help.

You can also run this code to test. Just install the 4 modules in first 4 lines and enter your MySQL passwd. Also create a file named EncryptionKey.dat. Thanks.

import tkinter as tk import tkinter.messagebox import secrets,pickle import mysql.connector as ms connect=ms.connect(host='localhost',passwd='YourPasswword',user='root') cursor=connect.cursor() cursor.execute("CREATE DATABASE IF NOT EXISTS EN_DEC_CHAT_RECORDS;") cursor.execute("USE EN_DEC_CHAT_RECORDS;") cursor.execute("""CREATE TABLE IF NOT EXISTS chat_record( ChatDate_Time DATETIME PRIMARY KEY, ChatMsg VARCHAR(10000) );""") connect.commit() root=tk.Tk() #_____________________________________________________ def ASCII(): string1="" for i in range(0,128): string1+=chr(i) return list(string1) lst=ASCII() #_____________________________________________________ try: #key generator def keygen(texts): k="" for i in texts: x=secrets.randbelow(127) k+=chr(x) return k #_____________________________________________________ # Message Encryptor def encrypt(texts,key): k1=list(key) msg="" for i,char in enumerate(texts): sum1=(lst.index(char)+lst.index(k1[i]))%128 msg+=lst[sum1] return msg except Exception as e: tkinter.messagebox.showerror("Error_Occured",f"Unexpected error {e} occured") #_____________________________________________________ #Message Decryptor def decrypt(): cursor.execute("SELECT ChatMsg FROM chat_record WHERE ChatDate_Time=(SELECT max(ChatDate_Time) FROM chat_record);") msg=cursor.fetchone()[0] connect.commit() if msg is None: tkinter.messagebox.showerror("Message Not Found Error","Kindly Enter Your Msg to Send") with open("EncryptionKey.dat","rb") as keyf: sharedkey=pickle.load(keyf) label = tk.Label(root, text=f"DECIPHERING MESSAGE: {msg}nVIA PROVIDED KEY: {sharedkey}") label.pack(padx=20,pady=20) recieved="" for i,j in zip(msg,sharedkey): diff2=(lst.index(i)-lst.index(j))%128 recieved+=lst[diff2] label = tk.Label(root, text=f"THE DECRYPTED MESSAGE IS: {recieved}") label.pack(padx=20,pady=20) #_____________________________________________________ #Tkinter GUI for application def GUI(): root.geometry("1200x600") root.title("ENCRYPTOR-INTERFACE") label=tk.Label(root, text=" EndecChat ",font=('San Francisco',36),bg="DarkSlateBlue") label.pack(padx=20,pady=20) contents=tk.Entry(root, font=("San Francisco", 18,),bg="DarkSlateBlue") contents.pack(padx=20,pady=20) buttonframe=tk.Frame(root) buttonframe.columnconfigure(0, weight=1) buttonframe.columnconfigure(1, weight=1) #_____________________________________________________ #file management and msg sharing via MySQL def ProcessedText(): texts=contents.get() key=keygen(texts) global encryptedmsg encryptedmsg=encrypt(texts,key) try: cursor.execute(f"INSERT INTO chat_record(ChatDate_time,ChatMsg) VALUE(NOW(),'{encryptedmsg}')") with open("EncryptionKey.dat","wb") as keyfile: pickle.dump(key,keyfile) tkinter.messagebox.showinfo("Success", "Message Encrypted Successfully") except FileNotFoundError as FnF: tkinter.messagebox.showerror("Error_Occured", f"{FnF}") #_____________________________________________________ btn1=tk.Button(root, text="Save",font=("San Francisco", 11),command=lambda: [ProcessedText(), contents.delete(0, tk.END)]) btn1.place(x=950,y=120,height=50,width=100) btn3=tk.Button(buttonframe, text="Decrypt",font=("San Francisco", 11),command=decrypt) btn3.grid(row=0,column=0,sticky=tk.E+tk.W) btn4=tk.Button(buttonframe, text="Exit",font=("San Francisco", 11),command=root.quit) btn4.grid(row=0,column=1,sticky=tk.E+tk.W) #_____________________________________________________ buttonframe.pack(fill='x') root.configure(bg="Gray9") root.mainloop() GUI() import tkinter as tk import tkinter.messagebox import secrets,pickle import mysql.connector as ms connect=ms.connect(host='localhost',passwd='Avengers@123',user='root') cursor=connect.cursor() cursor.execute("CREATE DATABASE IF NOT EXISTS EN_DEC_CHAT_RECORDS;") cursor.execute("USE EN_DEC_CHAT_RECORDS;") cursor.execute("""CREATE TABLE IF NOT EXISTS chat_record( ChatDate_Time DATETIME PRIMARY KEY, ChatMsg VARCHAR(10000) );""") connect.commit() root=tk.Tk() #_____________________________________________________ def ASCII(): string1="" for i in range(0,128): string1+=chr(i) return list(string1) lst=ASCII() #_____________________________________________________ try: #key generator def keygen(texts): k="" for i in texts: x=secrets.randbelow(127) k+=chr(x) return k #_____________________________________________________ # Message Encryptor def encrypt(texts,key): k1=list(key) msg="" for i,char in enumerate(texts): sum1=(lst.index(char)+lst.index(k1[i]))%128 msg+=lst[sum1] return msg except Exception as e: tkinter.messagebox.showerror("Error_Occured",f"Unexpected error {e} occured") #_____________________________________________________ #Message Decryptor def decrypt(): cursor.execute("SELECT ChatMsg FROM chat_record WHERE ChatDate_Time=(SELECT max(ChatDate_Time) FROM chat_record);") msg=cursor.fetchone()[0] connect.commit() if msg is None: tkinter.messagebox.showerror("Message Not Found Error","Kindly Enter Your Msg to Send") with open("EncryptionKey.dat","rb") as keyf: sharedkey=pickle.load(keyf) label = tk.Label(root, text=f"DECIPHERING MESSAGE: {msg}nVIA PROVIDED KEY: {sharedkey}") label.pack(padx=20,pady=20) recieved="" for i,j in zip(msg,sharedkey): diff2=(lst.index(i)-lst.index(j))%128 recieved+=lst[diff2] label = tk.Label(root, text=f"THE DECRYPTED MESSAGE IS: {recieved}") label.pack(padx=20,pady=20) #_____________________________________________________ #Tkinter GUI for application def GUI(): root.geometry("1200x600") root.title("ENCRYPTOR-INTERFACE") label=tk.Label(root, text=" EndecChat ",font=('San Francisco',36),bg="DarkSlateBlue") label.pack(padx=20,pady=20) contents=tk.Entry(root, font=("San Francisco", 18,),bg="DarkSlateBlue") contents.pack(padx=20,pady=20) buttonframe=tk.Frame(root) buttonframe.columnconfigure(0, weight=1) buttonframe.columnconfigure(1, weight=1) #_____________________________________________________ #file management and msg sharing via MySQL def ProcessedText(): texts=contents.get() key=keygen(texts) global encryptedmsg encryptedmsg=encrypt(texts,key) try: cursor.execute(f"INSERT INTO chat_record(ChatDate_time,ChatMsg) VALUE(NOW(),'{encryptedmsg}')") with open("EncryptionKey.dat","wb") as keyfile: pickle.dump(key,keyfile) tkinter.messagebox.showinfo("Success", "Message Encrypted Successfully") except FileNotFoundError as FnF: tkinter.messagebox.showerror("Error_Occured", f"{FnF}") #_____________________________________________________ btn1=tk.Button(root, text="Save",font=("San Francisco", 11),command=lambda: [ProcessedText(), contents.delete(0, tk.END)]) btn1.place(x=950,y=120,height=50,width=100) btn3=tk.Button(buttonframe, text="Decrypt",font=("San Francisco", 11),command=decrypt) btn3.grid(row=0,column=0,sticky=tk.E+tk.W) btn4=tk.Button(buttonframe, text="Exit",font=("San Francisco", 11),command=root.quit) btn4.grid(row=0,column=1,sticky=tk.E+tk.W) #_____________________________________________________ buttonframe.pack(fill='x') root.configure(bg="Gray9") root.mainloop() GUI() 

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

​r/learnpython idk much about programming, learning. I just did this project and needed suggestions for improvements as well as recommendations on what topics should i focus on & learn. I’d be grateful for your help. You can also run this code to test. Just install the 4 modules in first 4 lines and enter your MySQL passwd. Also create a file named EncryptionKey.dat. Thanks. import tkinter as tk import tkinter.messagebox import secrets,pickle import mysql.connector as ms connect=ms.connect(host=’localhost’,passwd=’YourPasswword’,user=’root’) cursor=connect.cursor() cursor.execute(“CREATE DATABASE IF NOT EXISTS EN_DEC_CHAT_RECORDS;”) cursor.execute(“USE EN_DEC_CHAT_RECORDS;”) cursor.execute(“””CREATE TABLE IF NOT EXISTS chat_record( ChatDate_Time DATETIME PRIMARY KEY, ChatMsg VARCHAR(10000) );”””) connect.commit() root=tk.Tk() #_____________________________________________________ def ASCII(): string1=”” for i in range(0,128): string1+=chr(i) return list(string1) lst=ASCII() #_____________________________________________________ try: #key generator def keygen(texts): k=”” for i in texts: x=secrets.randbelow(127) k+=chr(x) return k #_____________________________________________________ # Message Encryptor def encrypt(texts,key): k1=list(key) msg=”” for i,char in enumerate(texts): sum1=(lst.index(char)+lst.index(k1[i]))%128 msg+=lst[sum1] return msg except Exception as e: tkinter.messagebox.showerror(“Error_Occured”,f”Unexpected error {e} occured”) #_____________________________________________________ #Message Decryptor def decrypt(): cursor.execute(“SELECT ChatMsg FROM chat_record WHERE ChatDate_Time=(SELECT max(ChatDate_Time) FROM chat_record);”) msg=cursor.fetchone()[0] connect.commit() if msg is None: tkinter.messagebox.showerror(“Message Not Found Error”,”Kindly Enter Your Msg to Send”) with open(“EncryptionKey.dat”,”rb”) as keyf: sharedkey=pickle.load(keyf) label = tk.Label(root, text=f”DECIPHERING MESSAGE: {msg}nVIA PROVIDED KEY: {sharedkey}”) label.pack(padx=20,pady=20) recieved=”” for i,j in zip(msg,sharedkey): diff2=(lst.index(i)-lst.index(j))%128 recieved+=lst[diff2] label = tk.Label(root, text=f”THE DECRYPTED MESSAGE IS: {recieved}”) label.pack(padx=20,pady=20) #_____________________________________________________ #Tkinter GUI for application def GUI(): root.geometry(“1200×600”) root.title(“ENCRYPTOR-INTERFACE”) label=tk.Label(root, text=” EndecChat “,font=(‘San Francisco’,36),bg=”DarkSlateBlue”) label.pack(padx=20,pady=20) contents=tk.Entry(root, font=(“San Francisco”, 18,),bg=”DarkSlateBlue”) contents.pack(padx=20,pady=20) buttonframe=tk.Frame(root) buttonframe.columnconfigure(0, weight=1) buttonframe.columnconfigure(1, weight=1) #_____________________________________________________ #file management and msg sharing via MySQL def ProcessedText(): texts=contents.get() key=keygen(texts) global encryptedmsg encryptedmsg=encrypt(texts,key) try: cursor.execute(f”INSERT INTO chat_record(ChatDate_time,ChatMsg) VALUE(NOW(),'{encryptedmsg}’)”) with open(“EncryptionKey.dat”,”wb”) as keyfile: pickle.dump(key,keyfile) tkinter.messagebox.showinfo(“Success”, “Message Encrypted Successfully”) except FileNotFoundError as FnF: tkinter.messagebox.showerror(“Error_Occured”, f”{FnF}”) #_____________________________________________________ btn1=tk.Button(root, text=”Save”,font=(“San Francisco”, 11),command=lambda: [ProcessedText(), contents.delete(0, tk.END)]) btn1.place(x=950,y=120,height=50,width=100) btn3=tk.Button(buttonframe, text=”Decrypt”,font=(“San Francisco”, 11),command=decrypt) btn3.grid(row=0,column=0,sticky=tk.E+tk.W) btn4=tk.Button(buttonframe, text=”Exit”,font=(“San Francisco”, 11),command=root.quit) btn4.grid(row=0,column=1,sticky=tk.E+tk.W) #_____________________________________________________ buttonframe.pack(fill=’x’) root.configure(bg=”Gray9″) root.mainloop() GUI() import tkinter as tk import tkinter.messagebox import secrets,pickle import mysql.connector as ms connect=ms.connect(host=’localhost’,passwd=’Avengers@123′,user=’root’) cursor=connect.cursor() cursor.execute(“CREATE DATABASE IF NOT EXISTS EN_DEC_CHAT_RECORDS;”) cursor.execute(“USE EN_DEC_CHAT_RECORDS;”) cursor.execute(“””CREATE TABLE IF NOT EXISTS chat_record( ChatDate_Time DATETIME PRIMARY KEY, ChatMsg VARCHAR(10000) );”””) connect.commit() root=tk.Tk() #_____________________________________________________ def ASCII(): string1=”” for i in range(0,128): string1+=chr(i) return list(string1) lst=ASCII() #_____________________________________________________ try: #key generator def keygen(texts): k=”” for i in texts: x=secrets.randbelow(127) k+=chr(x) return k #_____________________________________________________ # Message Encryptor def encrypt(texts,key): k1=list(key) msg=”” for i,char in enumerate(texts): sum1=(lst.index(char)+lst.index(k1[i]))%128 msg+=lst[sum1] return msg except Exception as e: tkinter.messagebox.showerror(“Error_Occured”,f”Unexpected error {e} occured”) #_____________________________________________________ #Message Decryptor def decrypt(): cursor.execute(“SELECT ChatMsg FROM chat_record WHERE ChatDate_Time=(SELECT max(ChatDate_Time) FROM chat_record);”) msg=cursor.fetchone()[0] connect.commit() if msg is None: tkinter.messagebox.showerror(“Message Not Found Error”,”Kindly Enter Your Msg to Send”) with open(“EncryptionKey.dat”,”rb”) as keyf: sharedkey=pickle.load(keyf) label = tk.Label(root, text=f”DECIPHERING MESSAGE: {msg}nVIA PROVIDED KEY: {sharedkey}”) label.pack(padx=20,pady=20) recieved=”” for i,j in zip(msg,sharedkey): diff2=(lst.index(i)-lst.index(j))%128 recieved+=lst[diff2] label = tk.Label(root, text=f”THE DECRYPTED MESSAGE IS: {recieved}”) label.pack(padx=20,pady=20) #_____________________________________________________ #Tkinter GUI for application def GUI(): root.geometry(“1200×600”) root.title(“ENCRYPTOR-INTERFACE”) label=tk.Label(root, text=” EndecChat “,font=(‘San Francisco’,36),bg=”DarkSlateBlue”) label.pack(padx=20,pady=20) contents=tk.Entry(root, font=(“San Francisco”, 18,),bg=”DarkSlateBlue”) contents.pack(padx=20,pady=20) buttonframe=tk.Frame(root) buttonframe.columnconfigure(0, weight=1) buttonframe.columnconfigure(1, weight=1) #_____________________________________________________ #file management and msg sharing via MySQL def ProcessedText(): texts=contents.get() key=keygen(texts) global encryptedmsg encryptedmsg=encrypt(texts,key) try: cursor.execute(f”INSERT INTO chat_record(ChatDate_time,ChatMsg) VALUE(NOW(),'{encryptedmsg}’)”) with open(“EncryptionKey.dat”,”wb”) as keyfile: pickle.dump(key,keyfile) tkinter.messagebox.showinfo(“Success”, “Message Encrypted Successfully”) except FileNotFoundError as FnF: tkinter.messagebox.showerror(“Error_Occured”, f”{FnF}”) #_____________________________________________________ btn1=tk.Button(root, text=”Save”,font=(“San Francisco”, 11),command=lambda: [ProcessedText(), contents.delete(0, tk.END)]) btn1.place(x=950,y=120,height=50,width=100) btn3=tk.Button(buttonframe, text=”Decrypt”,font=(“San Francisco”, 11),command=decrypt) btn3.grid(row=0,column=0,sticky=tk.E+tk.W) btn4=tk.Button(buttonframe, text=”Exit”,font=(“San Francisco”, 11),command=root.quit) btn4.grid(row=0,column=1,sticky=tk.E+tk.W) #_____________________________________________________ buttonframe.pack(fill=’x’) root.configure(bg=”Gray9″) root.mainloop() GUI() submitted by /u/DiligentBank7831 [link] [comments] 

idk much about programming, learning. I just did this project and needed suggestions for improvements as well as recommendations on what topics should i focus on & learn. I’d be grateful for your help.

You can also run this code to test. Just install the 4 modules in first 4 lines and enter your MySQL passwd. Also create a file named EncryptionKey.dat. Thanks.

import tkinter as tk import tkinter.messagebox import secrets,pickle import mysql.connector as ms connect=ms.connect(host='localhost',passwd='YourPasswword',user='root') cursor=connect.cursor() cursor.execute("CREATE DATABASE IF NOT EXISTS EN_DEC_CHAT_RECORDS;") cursor.execute("USE EN_DEC_CHAT_RECORDS;") cursor.execute("""CREATE TABLE IF NOT EXISTS chat_record( ChatDate_Time DATETIME PRIMARY KEY, ChatMsg VARCHAR(10000) );""") connect.commit() root=tk.Tk() #_____________________________________________________ def ASCII(): string1="" for i in range(0,128): string1+=chr(i) return list(string1) lst=ASCII() #_____________________________________________________ try: #key generator def keygen(texts): k="" for i in texts: x=secrets.randbelow(127) k+=chr(x) return k #_____________________________________________________ # Message Encryptor def encrypt(texts,key): k1=list(key) msg="" for i,char in enumerate(texts): sum1=(lst.index(char)+lst.index(k1[i]))%128 msg+=lst[sum1] return msg except Exception as e: tkinter.messagebox.showerror("Error_Occured",f"Unexpected error {e} occured") #_____________________________________________________ #Message Decryptor def decrypt(): cursor.execute("SELECT ChatMsg FROM chat_record WHERE ChatDate_Time=(SELECT max(ChatDate_Time) FROM chat_record);") msg=cursor.fetchone()[0] connect.commit() if msg is None: tkinter.messagebox.showerror("Message Not Found Error","Kindly Enter Your Msg to Send") with open("EncryptionKey.dat","rb") as keyf: sharedkey=pickle.load(keyf) label = tk.Label(root, text=f"DECIPHERING MESSAGE: {msg}nVIA PROVIDED KEY: {sharedkey}") label.pack(padx=20,pady=20) recieved="" for i,j in zip(msg,sharedkey): diff2=(lst.index(i)-lst.index(j))%128 recieved+=lst[diff2] label = tk.Label(root, text=f"THE DECRYPTED MESSAGE IS: {recieved}") label.pack(padx=20,pady=20) #_____________________________________________________ #Tkinter GUI for application def GUI(): root.geometry("1200x600") root.title("ENCRYPTOR-INTERFACE") label=tk.Label(root, text=" EndecChat ",font=('San Francisco',36),bg="DarkSlateBlue") label.pack(padx=20,pady=20) contents=tk.Entry(root, font=("San Francisco", 18,),bg="DarkSlateBlue") contents.pack(padx=20,pady=20) buttonframe=tk.Frame(root) buttonframe.columnconfigure(0, weight=1) buttonframe.columnconfigure(1, weight=1) #_____________________________________________________ #file management and msg sharing via MySQL def ProcessedText(): texts=contents.get() key=keygen(texts) global encryptedmsg encryptedmsg=encrypt(texts,key) try: cursor.execute(f"INSERT INTO chat_record(ChatDate_time,ChatMsg) VALUE(NOW(),'{encryptedmsg}')") with open("EncryptionKey.dat","wb") as keyfile: pickle.dump(key,keyfile) tkinter.messagebox.showinfo("Success", "Message Encrypted Successfully") except FileNotFoundError as FnF: tkinter.messagebox.showerror("Error_Occured", f"{FnF}") #_____________________________________________________ btn1=tk.Button(root, text="Save",font=("San Francisco", 11),command=lambda: [ProcessedText(), contents.delete(0, tk.END)]) btn1.place(x=950,y=120,height=50,width=100) btn3=tk.Button(buttonframe, text="Decrypt",font=("San Francisco", 11),command=decrypt) btn3.grid(row=0,column=0,sticky=tk.E+tk.W) btn4=tk.Button(buttonframe, text="Exit",font=("San Francisco", 11),command=root.quit) btn4.grid(row=0,column=1,sticky=tk.E+tk.W) #_____________________________________________________ buttonframe.pack(fill='x') root.configure(bg="Gray9") root.mainloop() GUI() import tkinter as tk import tkinter.messagebox import secrets,pickle import mysql.connector as ms connect=ms.connect(host='localhost',passwd='Avengers@123',user='root') cursor=connect.cursor() cursor.execute("CREATE DATABASE IF NOT EXISTS EN_DEC_CHAT_RECORDS;") cursor.execute("USE EN_DEC_CHAT_RECORDS;") cursor.execute("""CREATE TABLE IF NOT EXISTS chat_record( ChatDate_Time DATETIME PRIMARY KEY, ChatMsg VARCHAR(10000) );""") connect.commit() root=tk.Tk() #_____________________________________________________ def ASCII(): string1="" for i in range(0,128): string1+=chr(i) return list(string1) lst=ASCII() #_____________________________________________________ try: #key generator def keygen(texts): k="" for i in texts: x=secrets.randbelow(127) k+=chr(x) return k #_____________________________________________________ # Message Encryptor def encrypt(texts,key): k1=list(key) msg="" for i,char in enumerate(texts): sum1=(lst.index(char)+lst.index(k1[i]))%128 msg+=lst[sum1] return msg except Exception as e: tkinter.messagebox.showerror("Error_Occured",f"Unexpected error {e} occured") #_____________________________________________________ #Message Decryptor def decrypt(): cursor.execute("SELECT ChatMsg FROM chat_record WHERE ChatDate_Time=(SELECT max(ChatDate_Time) FROM chat_record);") msg=cursor.fetchone()[0] connect.commit() if msg is None: tkinter.messagebox.showerror("Message Not Found Error","Kindly Enter Your Msg to Send") with open("EncryptionKey.dat","rb") as keyf: sharedkey=pickle.load(keyf) label = tk.Label(root, text=f"DECIPHERING MESSAGE: {msg}nVIA PROVIDED KEY: {sharedkey}") label.pack(padx=20,pady=20) recieved="" for i,j in zip(msg,sharedkey): diff2=(lst.index(i)-lst.index(j))%128 recieved+=lst[diff2] label = tk.Label(root, text=f"THE DECRYPTED MESSAGE IS: {recieved}") label.pack(padx=20,pady=20) #_____________________________________________________ #Tkinter GUI for application def GUI(): root.geometry("1200x600") root.title("ENCRYPTOR-INTERFACE") label=tk.Label(root, text=" EndecChat ",font=('San Francisco',36),bg="DarkSlateBlue") label.pack(padx=20,pady=20) contents=tk.Entry(root, font=("San Francisco", 18,),bg="DarkSlateBlue") contents.pack(padx=20,pady=20) buttonframe=tk.Frame(root) buttonframe.columnconfigure(0, weight=1) buttonframe.columnconfigure(1, weight=1) #_____________________________________________________ #file management and msg sharing via MySQL def ProcessedText(): texts=contents.get() key=keygen(texts) global encryptedmsg encryptedmsg=encrypt(texts,key) try: cursor.execute(f"INSERT INTO chat_record(ChatDate_time,ChatMsg) VALUE(NOW(),'{encryptedmsg}')") with open("EncryptionKey.dat","wb") as keyfile: pickle.dump(key,keyfile) tkinter.messagebox.showinfo("Success", "Message Encrypted Successfully") except FileNotFoundError as FnF: tkinter.messagebox.showerror("Error_Occured", f"{FnF}") #_____________________________________________________ btn1=tk.Button(root, text="Save",font=("San Francisco", 11),command=lambda: [ProcessedText(), contents.delete(0, tk.END)]) btn1.place(x=950,y=120,height=50,width=100) btn3=tk.Button(buttonframe, text="Decrypt",font=("San Francisco", 11),command=decrypt) btn3.grid(row=0,column=0,sticky=tk.E+tk.W) btn4=tk.Button(buttonframe, text="Exit",font=("San Francisco", 11),command=root.quit) btn4.grid(row=0,column=1,sticky=tk.E+tk.W) #_____________________________________________________ buttonframe.pack(fill='x') root.configure(bg="Gray9") root.mainloop() GUI() 

submitted by /u/DiligentBank7831
[link] [comments]  idk much about programming, learning. I just did this project and needed suggestions for improvements as well as recommendations on what topics should i focus on & learn. I’d be grateful for your help. You can also run this code to test. Just install the 4 modules in first 4 lines and enter your MySQL passwd. Also create a file named EncryptionKey.dat. Thanks. import tkinter as tk import tkinter.messagebox import secrets,pickle import mysql.connector as ms connect=ms.connect(host=’localhost’,passwd=’YourPasswword’,user=’root’) cursor=connect.cursor() cursor.execute(“CREATE DATABASE IF NOT EXISTS EN_DEC_CHAT_RECORDS;”) cursor.execute(“USE EN_DEC_CHAT_RECORDS;”) cursor.execute(“””CREATE TABLE IF NOT EXISTS chat_record( ChatDate_Time DATETIME PRIMARY KEY, ChatMsg VARCHAR(10000) );”””) connect.commit() root=tk.Tk() #_____________________________________________________ def ASCII(): string1=”” for i in range(0,128): string1+=chr(i) return list(string1) lst=ASCII() #_____________________________________________________ try: #key generator def keygen(texts): k=”” for i in texts: x=secrets.randbelow(127) k+=chr(x) return k #_____________________________________________________ # Message Encryptor def encrypt(texts,key): k1=list(key) msg=”” for i,char in enumerate(texts): sum1=(lst.index(char)+lst.index(k1[i]))%128 msg+=lst[sum1] return msg except Exception as e: tkinter.messagebox.showerror(“Error_Occured”,f”Unexpected error {e} occured”) #_____________________________________________________ #Message Decryptor def decrypt(): cursor.execute(“SELECT ChatMsg FROM chat_record WHERE ChatDate_Time=(SELECT max(ChatDate_Time) FROM chat_record);”) msg=cursor.fetchone()[0] connect.commit() if msg is None: tkinter.messagebox.showerror(“Message Not Found Error”,”Kindly Enter Your Msg to Send”) with open(“EncryptionKey.dat”,”rb”) as keyf: sharedkey=pickle.load(keyf) label = tk.Label(root, text=f”DECIPHERING MESSAGE: {msg}nVIA PROVIDED KEY: {sharedkey}”) label.pack(padx=20,pady=20) recieved=”” for i,j in zip(msg,sharedkey): diff2=(lst.index(i)-lst.index(j))%128 recieved+=lst[diff2] label = tk.Label(root, text=f”THE DECRYPTED MESSAGE IS: {recieved}”) label.pack(padx=20,pady=20) #_____________________________________________________ #Tkinter GUI for application def GUI(): root.geometry(“1200×600”) root.title(“ENCRYPTOR-INTERFACE”) label=tk.Label(root, text=” EndecChat “,font=(‘San Francisco’,36),bg=”DarkSlateBlue”) label.pack(padx=20,pady=20) contents=tk.Entry(root, font=(“San Francisco”, 18,),bg=”DarkSlateBlue”) contents.pack(padx=20,pady=20) buttonframe=tk.Frame(root) buttonframe.columnconfigure(0, weight=1) buttonframe.columnconfigure(1, weight=1) #_____________________________________________________ #file management and msg sharing via MySQL def ProcessedText(): texts=contents.get() key=keygen(texts) global encryptedmsg encryptedmsg=encrypt(texts,key) try: cursor.execute(f”INSERT INTO chat_record(ChatDate_time,ChatMsg) VALUE(NOW(),'{encryptedmsg}’)”) with open(“EncryptionKey.dat”,”wb”) as keyfile: pickle.dump(key,keyfile) tkinter.messagebox.showinfo(“Success”, “Message Encrypted Successfully”) except FileNotFoundError as FnF: tkinter.messagebox.showerror(“Error_Occured”, f”{FnF}”) #_____________________________________________________ btn1=tk.Button(root, text=”Save”,font=(“San Francisco”, 11),command=lambda: [ProcessedText(), contents.delete(0, tk.END)]) btn1.place(x=950,y=120,height=50,width=100) btn3=tk.Button(buttonframe, text=”Decrypt”,font=(“San Francisco”, 11),command=decrypt) btn3.grid(row=0,column=0,sticky=tk.E+tk.W) btn4=tk.Button(buttonframe, text=”Exit”,font=(“San Francisco”, 11),command=root.quit) btn4.grid(row=0,column=1,sticky=tk.E+tk.W) #_____________________________________________________ buttonframe.pack(fill=’x’) root.configure(bg=”Gray9″) root.mainloop() GUI() import tkinter as tk import tkinter.messagebox import secrets,pickle import mysql.connector as ms connect=ms.connect(host=’localhost’,passwd=’Avengers@123′,user=’root’) cursor=connect.cursor() cursor.execute(“CREATE DATABASE IF NOT EXISTS EN_DEC_CHAT_RECORDS;”) cursor.execute(“USE EN_DEC_CHAT_RECORDS;”) cursor.execute(“””CREATE TABLE IF NOT EXISTS chat_record( ChatDate_Time DATETIME PRIMARY KEY, ChatMsg VARCHAR(10000) );”””) connect.commit() root=tk.Tk() #_____________________________________________________ def ASCII(): string1=”” for i in range(0,128): string1+=chr(i) return list(string1) lst=ASCII() #_____________________________________________________ try: #key generator def keygen(texts): k=”” for i in texts: x=secrets.randbelow(127) k+=chr(x) return k #_____________________________________________________ # Message Encryptor def encrypt(texts,key): k1=list(key) msg=”” for i,char in enumerate(texts): sum1=(lst.index(char)+lst.index(k1[i]))%128 msg+=lst[sum1] return msg except Exception as e: tkinter.messagebox.showerror(“Error_Occured”,f”Unexpected error {e} occured”) #_____________________________________________________ #Message Decryptor def decrypt(): cursor.execute(“SELECT ChatMsg FROM chat_record WHERE ChatDate_Time=(SELECT max(ChatDate_Time) FROM chat_record);”) msg=cursor.fetchone()[0] connect.commit() if msg is None: tkinter.messagebox.showerror(“Message Not Found Error”,”Kindly Enter Your Msg to Send”) with open(“EncryptionKey.dat”,”rb”) as keyf: sharedkey=pickle.load(keyf) label = tk.Label(root, text=f”DECIPHERING MESSAGE: {msg}nVIA PROVIDED KEY: {sharedkey}”) label.pack(padx=20,pady=20) recieved=”” for i,j in zip(msg,sharedkey): diff2=(lst.index(i)-lst.index(j))%128 recieved+=lst[diff2] label = tk.Label(root, text=f”THE DECRYPTED MESSAGE IS: {recieved}”) label.pack(padx=20,pady=20) #_____________________________________________________ #Tkinter GUI for application def GUI(): root.geometry(“1200×600”) root.title(“ENCRYPTOR-INTERFACE”) label=tk.Label(root, text=” EndecChat “,font=(‘San Francisco’,36),bg=”DarkSlateBlue”) label.pack(padx=20,pady=20) contents=tk.Entry(root, font=(“San Francisco”, 18,),bg=”DarkSlateBlue”) contents.pack(padx=20,pady=20) buttonframe=tk.Frame(root) buttonframe.columnconfigure(0, weight=1) buttonframe.columnconfigure(1, weight=1) #_____________________________________________________ #file management and msg sharing via MySQL def ProcessedText(): texts=contents.get() key=keygen(texts) global encryptedmsg encryptedmsg=encrypt(texts,key) try: cursor.execute(f”INSERT INTO chat_record(ChatDate_time,ChatMsg) VALUE(NOW(),'{encryptedmsg}’)”) with open(“EncryptionKey.dat”,”wb”) as keyfile: pickle.dump(key,keyfile) tkinter.messagebox.showinfo(“Success”, “Message Encrypted Successfully”) except FileNotFoundError as FnF: tkinter.messagebox.showerror(“Error_Occured”, f”{FnF}”) #_____________________________________________________ btn1=tk.Button(root, text=”Save”,font=(“San Francisco”, 11),command=lambda: [ProcessedText(), contents.delete(0, tk.END)]) btn1.place(x=950,y=120,height=50,width=100) btn3=tk.Button(buttonframe, text=”Decrypt”,font=(“San Francisco”, 11),command=decrypt) btn3.grid(row=0,column=0,sticky=tk.E+tk.W) btn4=tk.Button(buttonframe, text=”Exit”,font=(“San Francisco”, 11),command=root.quit) btn4.grid(row=0,column=1,sticky=tk.E+tk.W) #_____________________________________________________ buttonframe.pack(fill=’x’) root.configure(bg=”Gray9″) root.mainloop() GUI() submitted by /u/DiligentBank7831 [link] [comments]

Read more

Help in Understanding How Variables Update /u/WillingnessPast5294 Python Education

Help in Understanding How Variables Update /u/WillingnessPast5294 Python Education

So I was making some test system and came across with this problem.

Here’s the code:

name = '' def username(name): print('What is your name?n') name = input().title() print('Is this correct?n', name, 'nY/N') response = input().upper() if response == 'Y': pass elif response == 'N': name = input().title() username(name) print(name) 

The problem was, it wasn’t printing the updated value(the name) but the first value. Then I found the solution which is this:

def username(): print('What is your name?n') name = input().title() print('Is this correct?n', name, 'nY/N') response = input().upper() if response == 'Y': return name elif response == 'N': name = input().title() return name name = username() print(name) 

Why did this work and not the other one? I inputted the variable inside the function and returned the value, so it should’ve had printed it. Does functions not affect variables outside of it even if it the variable is put in as an argument of the function? Does the variable not update if I don’t use the ‘global’ variable?

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

​r/learnpython So I was making some test system and came across with this problem. Here’s the code: name = ” def username(name): print(‘What is your name?n’) name = input().title() print(‘Is this correct?n’, name, ‘nY/N’) response = input().upper() if response == ‘Y’: pass elif response == ‘N’: name = input().title() username(name) print(name) The problem was, it wasn’t printing the updated value(the name) but the first value. Then I found the solution which is this: def username(): print(‘What is your name?n’) name = input().title() print(‘Is this correct?n’, name, ‘nY/N’) response = input().upper() if response == ‘Y’: return name elif response == ‘N’: name = input().title() return name name = username() print(name) Why did this work and not the other one? I inputted the variable inside the function and returned the value, so it should’ve had printed it. Does functions not affect variables outside of it even if it the variable is put in as an argument of the function? Does the variable not update if I don’t use the ‘global’ variable? submitted by /u/WillingnessPast5294 [link] [comments] 

So I was making some test system and came across with this problem.

Here’s the code:

name = '' def username(name): print('What is your name?n') name = input().title() print('Is this correct?n', name, 'nY/N') response = input().upper() if response == 'Y': pass elif response == 'N': name = input().title() username(name) print(name) 

The problem was, it wasn’t printing the updated value(the name) but the first value. Then I found the solution which is this:

def username(): print('What is your name?n') name = input().title() print('Is this correct?n', name, 'nY/N') response = input().upper() if response == 'Y': return name elif response == 'N': name = input().title() return name name = username() print(name) 

Why did this work and not the other one? I inputted the variable inside the function and returned the value, so it should’ve had printed it. Does functions not affect variables outside of it even if it the variable is put in as an argument of the function? Does the variable not update if I don’t use the ‘global’ variable?

submitted by /u/WillingnessPast5294
[link] [comments]  So I was making some test system and came across with this problem. Here’s the code: name = ” def username(name): print(‘What is your name?n’) name = input().title() print(‘Is this correct?n’, name, ‘nY/N’) response = input().upper() if response == ‘Y’: pass elif response == ‘N’: name = input().title() username(name) print(name) The problem was, it wasn’t printing the updated value(the name) but the first value. Then I found the solution which is this: def username(): print(‘What is your name?n’) name = input().title() print(‘Is this correct?n’, name, ‘nY/N’) response = input().upper() if response == ‘Y’: return name elif response == ‘N’: name = input().title() return name name = username() print(name) Why did this work and not the other one? I inputted the variable inside the function and returned the value, so it should’ve had printed it. Does functions not affect variables outside of it even if it the variable is put in as an argument of the function? Does the variable not update if I don’t use the ‘global’ variable? submitted by /u/WillingnessPast5294 [link] [comments]

Read more

Looking for some additional revision exercises for the 100 Days of Code course /u/kasdfgqwertu1 Python Education

Looking for some additional revision exercises for the 100 Days of Code course /u/kasdfgqwertu1 Python Education

Hello everybody,

Just started my journey with Python putting my hands on the course by Angela Yu. Everything goes great so far, but feels like it would be cool to do some revision exercises of the previous lessons on a daily basis to have my memory refreshed.

Does any of you acknowledge if there are sources that would provide me with such revision exercises to do so?

Will appreciate all answers and ideas 🙂

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

​r/learnpython Hello everybody, Just started my journey with Python putting my hands on the course by Angela Yu. Everything goes great so far, but feels like it would be cool to do some revision exercises of the previous lessons on a daily basis to have my memory refreshed. Does any of you acknowledge if there are sources that would provide me with such revision exercises to do so? Will appreciate all answers and ideas 🙂 submitted by /u/kasdfgqwertu1 [link] [comments] 

Hello everybody,

Just started my journey with Python putting my hands on the course by Angela Yu. Everything goes great so far, but feels like it would be cool to do some revision exercises of the previous lessons on a daily basis to have my memory refreshed.

Does any of you acknowledge if there are sources that would provide me with such revision exercises to do so?

Will appreciate all answers and ideas 🙂

submitted by /u/kasdfgqwertu1
[link] [comments]  Hello everybody, Just started my journey with Python putting my hands on the course by Angela Yu. Everything goes great so far, but feels like it would be cool to do some revision exercises of the previous lessons on a daily basis to have my memory refreshed. Does any of you acknowledge if there are sources that would provide me with such revision exercises to do so? Will appreciate all answers and ideas 🙂 submitted by /u/kasdfgqwertu1 [link] [comments]

Read more

Communities around monitoring Robin Stocks / Robinhood API? /u/Just_Language_41 Python Education

Communities around monitoring Robin Stocks / Robinhood API? /u/Just_Language_41 Python Education

I’m trying to build an app using the Robin Stocks library to make trades with Robinhood’s API. Recently I had to download the robin stocks GitHub repo to get the most recent changes since the version available through pip wasn’t working. I’m wondering if anyone has suggestions on how to stay on top of such changes in an API or if anyone knows of communities which are already doing this.

The best I could think of is to test my code regularly, and to set up notifications for the Robin Stocks GitHub repo.

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

​r/learnpython I’m trying to build an app using the Robin Stocks library to make trades with Robinhood’s API. Recently I had to download the robin stocks GitHub repo to get the most recent changes since the version available through pip wasn’t working. I’m wondering if anyone has suggestions on how to stay on top of such changes in an API or if anyone knows of communities which are already doing this. The best I could think of is to test my code regularly, and to set up notifications for the Robin Stocks GitHub repo. submitted by /u/Just_Language_41 [link] [comments] 

I’m trying to build an app using the Robin Stocks library to make trades with Robinhood’s API. Recently I had to download the robin stocks GitHub repo to get the most recent changes since the version available through pip wasn’t working. I’m wondering if anyone has suggestions on how to stay on top of such changes in an API or if anyone knows of communities which are already doing this.

The best I could think of is to test my code regularly, and to set up notifications for the Robin Stocks GitHub repo.

submitted by /u/Just_Language_41
[link] [comments]  I’m trying to build an app using the Robin Stocks library to make trades with Robinhood’s API. Recently I had to download the robin stocks GitHub repo to get the most recent changes since the version available through pip wasn’t working. I’m wondering if anyone has suggestions on how to stay on top of such changes in an API or if anyone knows of communities which are already doing this. The best I could think of is to test my code regularly, and to set up notifications for the Robin Stocks GitHub repo. submitted by /u/Just_Language_41 [link] [comments]

Read more

How to toggle a while function? /u/asdasdadsdasd Python Education

How to toggle a while function? /u/asdasdadsdasd Python Education

if keyboard.on_press("F7"): if start == 0: start = 1 elif start == 1: start = 0 while True: if keyboard.on_press("F7"): if start == 0: start = 1 elif start == 1: start = 0 if start == 1: PlaceBlocks() time.sleep(0.1) BreakBlocks() time.sleep(0.1) 

How do I make the script toggleable using the f7 key? This for some reason returns me with an error.
I have Keyboard, pyautogui, time, win32api, win32con imported.

error I get is:
TypeError: ‘str’ object is not callable

Traceback (most recent call last):

File “C:Users*****AppDataLocalProgramsPythonPython310libsite-packageskeyboard_generic.py”, line 22, in invoke_handlers

if handler(event):

File “C:Users*****AppDataLocalProgramsPythonPython310libsite-packageskeyboard__init__.py”, line 474, in <lambda>

return hook(lambda e: e.event_type == KEY_UP or callback(e), suppress=suppress)

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

​r/learnpython if keyboard.on_press(“F7”): if start == 0: start = 1 elif start == 1: start = 0 while True: if keyboard.on_press(“F7”): if start == 0: start = 1 elif start == 1: start = 0 if start == 1: PlaceBlocks() time.sleep(0.1) BreakBlocks() time.sleep(0.1) How do I make the script toggleable using the f7 key? This for some reason returns me with an error. I have Keyboard, pyautogui, time, win32api, win32con imported. error I get is: TypeError: ‘str’ object is not callable Traceback (most recent call last): File “C:Users*****AppDataLocalProgramsPythonPython310libsite-packageskeyboard_generic.py”, line 22, in invoke_handlers if handler(event): File “C:Users*****AppDataLocalProgramsPythonPython310libsite-packageskeyboard__init__.py”, line 474, in <lambda> return hook(lambda e: e.event_type == KEY_UP or callback(e), suppress=suppress) submitted by /u/asdasdadsdasd [link] [comments] 

if keyboard.on_press("F7"): if start == 0: start = 1 elif start == 1: start = 0 while True: if keyboard.on_press("F7"): if start == 0: start = 1 elif start == 1: start = 0 if start == 1: PlaceBlocks() time.sleep(0.1) BreakBlocks() time.sleep(0.1) 

How do I make the script toggleable using the f7 key? This for some reason returns me with an error.
I have Keyboard, pyautogui, time, win32api, win32con imported.

error I get is:
TypeError: ‘str’ object is not callable

Traceback (most recent call last):

File “C:Users*****AppDataLocalProgramsPythonPython310libsite-packageskeyboard_generic.py”, line 22, in invoke_handlers

if handler(event):

File “C:Users*****AppDataLocalProgramsPythonPython310libsite-packageskeyboard__init__.py”, line 474, in <lambda>

return hook(lambda e: e.event_type == KEY_UP or callback(e), suppress=suppress)

submitted by /u/asdasdadsdasd
[link] [comments]  if keyboard.on_press(“F7”): if start == 0: start = 1 elif start == 1: start = 0 while True: if keyboard.on_press(“F7”): if start == 0: start = 1 elif start == 1: start = 0 if start == 1: PlaceBlocks() time.sleep(0.1) BreakBlocks() time.sleep(0.1) How do I make the script toggleable using the f7 key? This for some reason returns me with an error. I have Keyboard, pyautogui, time, win32api, win32con imported. error I get is: TypeError: ‘str’ object is not callable Traceback (most recent call last): File “C:Users*****AppDataLocalProgramsPythonPython310libsite-packageskeyboard_generic.py”, line 22, in invoke_handlers if handler(event): File “C:Users*****AppDataLocalProgramsPythonPython310libsite-packageskeyboard__init__.py”, line 474, in <lambda> return hook(lambda e: e.event_type == KEY_UP or callback(e), suppress=suppress) submitted by /u/asdasdadsdasd [link] [comments]

Read more

AsyncIO or Threading to consume RabbitMQ messages in a web service ? /u/Icy_Zookeepergame201 Python Education

AsyncIO or Threading to consume RabbitMQ messages in a web service ? /u/Icy_Zookeepergame201 Python Education

I am building a Python micro service using FastAPI. I have some basic REST API endpoints, with services, etc.

I would like my application to consume messages from a RabbitMQ message queue. I already wrote my consumer class (with pika) but I was wondering what was the best approach to run the consumer on the application start.

I do not really understand the differences between AsyncIO, Multiprocess and classic Threading in Python. What would be the best way to consume the message without blocking my program ?

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

​r/learnpython I am building a Python micro service using FastAPI. I have some basic REST API endpoints, with services, etc. I would like my application to consume messages from a RabbitMQ message queue. I already wrote my consumer class (with pika) but I was wondering what was the best approach to run the consumer on the application start. I do not really understand the differences between AsyncIO, Multiprocess and classic Threading in Python. What would be the best way to consume the message without blocking my program ? submitted by /u/Icy_Zookeepergame201 [link] [comments] 

I am building a Python micro service using FastAPI. I have some basic REST API endpoints, with services, etc.

I would like my application to consume messages from a RabbitMQ message queue. I already wrote my consumer class (with pika) but I was wondering what was the best approach to run the consumer on the application start.

I do not really understand the differences between AsyncIO, Multiprocess and classic Threading in Python. What would be the best way to consume the message without blocking my program ?

submitted by /u/Icy_Zookeepergame201
[link] [comments]  I am building a Python micro service using FastAPI. I have some basic REST API endpoints, with services, etc. I would like my application to consume messages from a RabbitMQ message queue. I already wrote my consumer class (with pika) but I was wondering what was the best approach to run the consumer on the application start. I do not really understand the differences between AsyncIO, Multiprocess and classic Threading in Python. What would be the best way to consume the message without blocking my program ? submitted by /u/Icy_Zookeepergame201 [link] [comments]

Read more