Working with Tagged PDFs/ PDF object manipulation /u/uglyraccoongang Python Education

Working with Tagged PDFs/ PDF object manipulation /u/uglyraccoongang Python Education

I have a specific task that I can do manually but can’t figure out how to automate. I need to modify the accessibility tags in a PDF so that <Figure> tags are not nested inside of <p> tags (basically replacing the parent with the grandparent).

Manual methods: In Acrobat, this can be done manually by bringing up the accessibility tags panel and moving them. In TextEdit (I’m on Mac), it can be done manually by changing the parent reference in the <Figure> object to the parent of the <p> object.

Automation attempts
JavaScript: I initially wanted to do this with JavaScript and the Acrobat API so that I could make it an Acrobat Action but I don’t know JavaScript that well and the documentation doesn’t cover working with the structure tree. I did try ChatGPT but it first said it wasn’t possible to do and then kept giving me code using a function that, as far as I can tell, doesn’t exist to get the root tag.

Python: I am much more comfortable working in Python so I tried both using libraries and working with the decoded binary but in both cases, the saved result had NO tags at all. Just loading and saving a PDF results in the tags and the PDF object containing them disappearing in the new PDF. Is there a way to open the PDF in Python the way that it is opened and modifiable in TextEdit? Using .decode() is not working for me despite trying different encodings.

Given the importance of accessibility in this era, I feel like I can’t be the only person who is trying to work with tagged PDFs but I cannot find any information on how to do it.

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

​r/learnpython I have a specific task that I can do manually but can’t figure out how to automate. I need to modify the accessibility tags in a PDF so that <Figure> tags are not nested inside of <p> tags (basically replacing the parent with the grandparent). Manual methods: In Acrobat, this can be done manually by bringing up the accessibility tags panel and moving them. In TextEdit (I’m on Mac), it can be done manually by changing the parent reference in the <Figure> object to the parent of the <p> object. Automation attempts JavaScript: I initially wanted to do this with JavaScript and the Acrobat API so that I could make it an Acrobat Action but I don’t know JavaScript that well and the documentation doesn’t cover working with the structure tree. I did try ChatGPT but it first said it wasn’t possible to do and then kept giving me code using a function that, as far as I can tell, doesn’t exist to get the root tag. Python: I am much more comfortable working in Python so I tried both using libraries and working with the decoded binary but in both cases, the saved result had NO tags at all. Just loading and saving a PDF results in the tags and the PDF object containing them disappearing in the new PDF. Is there a way to open the PDF in Python the way that it is opened and modifiable in TextEdit? Using .decode() is not working for me despite trying different encodings. Given the importance of accessibility in this era, I feel like I can’t be the only person who is trying to work with tagged PDFs but I cannot find any information on how to do it. submitted by /u/uglyraccoongang [link] [comments] 

I have a specific task that I can do manually but can’t figure out how to automate. I need to modify the accessibility tags in a PDF so that <Figure> tags are not nested inside of <p> tags (basically replacing the parent with the grandparent).

Manual methods: In Acrobat, this can be done manually by bringing up the accessibility tags panel and moving them. In TextEdit (I’m on Mac), it can be done manually by changing the parent reference in the <Figure> object to the parent of the <p> object.

Automation attempts
JavaScript: I initially wanted to do this with JavaScript and the Acrobat API so that I could make it an Acrobat Action but I don’t know JavaScript that well and the documentation doesn’t cover working with the structure tree. I did try ChatGPT but it first said it wasn’t possible to do and then kept giving me code using a function that, as far as I can tell, doesn’t exist to get the root tag.

Python: I am much more comfortable working in Python so I tried both using libraries and working with the decoded binary but in both cases, the saved result had NO tags at all. Just loading and saving a PDF results in the tags and the PDF object containing them disappearing in the new PDF. Is there a way to open the PDF in Python the way that it is opened and modifiable in TextEdit? Using .decode() is not working for me despite trying different encodings.

Given the importance of accessibility in this era, I feel like I can’t be the only person who is trying to work with tagged PDFs but I cannot find any information on how to do it.

submitted by /u/uglyraccoongang
[link] [comments]  I have a specific task that I can do manually but can’t figure out how to automate. I need to modify the accessibility tags in a PDF so that <Figure> tags are not nested inside of <p> tags (basically replacing the parent with the grandparent). Manual methods: In Acrobat, this can be done manually by bringing up the accessibility tags panel and moving them. In TextEdit (I’m on Mac), it can be done manually by changing the parent reference in the <Figure> object to the parent of the <p> object. Automation attempts JavaScript: I initially wanted to do this with JavaScript and the Acrobat API so that I could make it an Acrobat Action but I don’t know JavaScript that well and the documentation doesn’t cover working with the structure tree. I did try ChatGPT but it first said it wasn’t possible to do and then kept giving me code using a function that, as far as I can tell, doesn’t exist to get the root tag. Python: I am much more comfortable working in Python so I tried both using libraries and working with the decoded binary but in both cases, the saved result had NO tags at all. Just loading and saving a PDF results in the tags and the PDF object containing them disappearing in the new PDF. Is there a way to open the PDF in Python the way that it is opened and modifiable in TextEdit? Using .decode() is not working for me despite trying different encodings. Given the importance of accessibility in this era, I feel like I can’t be the only person who is trying to work with tagged PDFs but I cannot find any information on how to do it. submitted by /u/uglyraccoongang [link] [comments]

Read more

Standard way to work on Python Project /u/JordaarFin Python Education

Standard way to work on Python Project /u/JordaarFin Python Education

Hello Geeks!

I am wondering, what is the correct, and industry standard way to work on python project. To give a context, I am working at IT company as a Python developer (beginner). Till now, during my learning journey, I used python with Conda. I used Conda without any knowledge and followed random youtubers and their method of developing Python’s project. But now, I have just joined the organization and worked on some Python’s project. Actually, the way we are developing python’s project does not seem industry acceptable and professional way. We follow following steps when starting any new project. Provided that first we have installed Python globally for instance, version 3.9.

step 1: open project directory and in VS code’s terminal type following command
"C:UsersmynamePython3.9.1python.exe" -m venv project_env_name

here according to my understanding, we are creating project specific virtual environment using globally installed Python.

step 2: activating the virtual environment.

step 3: installing all the libraries of requirements.txt (if requirements.txt is there else install all the packages using “pip”).

Here I do not understand why we cannot use Conda instead of pip. When I ask this same question to one my senior, he replied to me that, Conda has some vulnerabilities which can hinder Company’s policy. So senior asked me to apply this method when working on any new project. But I do not think this is industry standard approach to work on python project. Could you Geeks please teach me industry standard way of doing it.

Thanks

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

​r/learnpython Hello Geeks! I am wondering, what is the correct, and industry standard way to work on python project. To give a context, I am working at IT company as a Python developer (beginner). Till now, during my learning journey, I used python with Conda. I used Conda without any knowledge and followed random youtubers and their method of developing Python’s project. But now, I have just joined the organization and worked on some Python’s project. Actually, the way we are developing python’s project does not seem industry acceptable and professional way. We follow following steps when starting any new project. Provided that first we have installed Python globally for instance, version 3.9. step 1: open project directory and in VS code’s terminal type following command “C:UsersmynamePython3.9.1python.exe” -m venv project_env_name here according to my understanding, we are creating project specific virtual environment using globally installed Python. step 2: activating the virtual environment. step 3: installing all the libraries of requirements.txt (if requirements.txt is there else install all the packages using “pip”). Here I do not understand why we cannot use Conda instead of pip. When I ask this same question to one my senior, he replied to me that, Conda has some vulnerabilities which can hinder Company’s policy. So senior asked me to apply this method when working on any new project. But I do not think this is industry standard approach to work on python project. Could you Geeks please teach me industry standard way of doing it. Thanks submitted by /u/JordaarFin [link] [comments] 

Hello Geeks!

I am wondering, what is the correct, and industry standard way to work on python project. To give a context, I am working at IT company as a Python developer (beginner). Till now, during my learning journey, I used python with Conda. I used Conda without any knowledge and followed random youtubers and their method of developing Python’s project. But now, I have just joined the organization and worked on some Python’s project. Actually, the way we are developing python’s project does not seem industry acceptable and professional way. We follow following steps when starting any new project. Provided that first we have installed Python globally for instance, version 3.9.

step 1: open project directory and in VS code’s terminal type following command
"C:UsersmynamePython3.9.1python.exe" -m venv project_env_name

here according to my understanding, we are creating project specific virtual environment using globally installed Python.

step 2: activating the virtual environment.

step 3: installing all the libraries of requirements.txt (if requirements.txt is there else install all the packages using “pip”).

Here I do not understand why we cannot use Conda instead of pip. When I ask this same question to one my senior, he replied to me that, Conda has some vulnerabilities which can hinder Company’s policy. So senior asked me to apply this method when working on any new project. But I do not think this is industry standard approach to work on python project. Could you Geeks please teach me industry standard way of doing it.

Thanks

submitted by /u/JordaarFin
[link] [comments]  Hello Geeks! I am wondering, what is the correct, and industry standard way to work on python project. To give a context, I am working at IT company as a Python developer (beginner). Till now, during my learning journey, I used python with Conda. I used Conda without any knowledge and followed random youtubers and their method of developing Python’s project. But now, I have just joined the organization and worked on some Python’s project. Actually, the way we are developing python’s project does not seem industry acceptable and professional way. We follow following steps when starting any new project. Provided that first we have installed Python globally for instance, version 3.9. step 1: open project directory and in VS code’s terminal type following command “C:UsersmynamePython3.9.1python.exe” -m venv project_env_name here according to my understanding, we are creating project specific virtual environment using globally installed Python. step 2: activating the virtual environment. step 3: installing all the libraries of requirements.txt (if requirements.txt is there else install all the packages using “pip”). Here I do not understand why we cannot use Conda instead of pip. When I ask this same question to one my senior, he replied to me that, Conda has some vulnerabilities which can hinder Company’s policy. So senior asked me to apply this method when working on any new project. But I do not think this is industry standard approach to work on python project. Could you Geeks please teach me industry standard way of doing it. Thanks submitted by /u/JordaarFin [link] [comments]

Read more

After covering 100s of mobile games this year on r/AndroidGaming, these are the 48 most impactful games of 2024, ranked in a single tier list! /u/NimbleThor Android

After covering 100s of mobile games this year on r/AndroidGaming, these are the 48 most impactful games of 2024, ranked in a single tier list! /u/NimbleThor Android

2024 is coming to an end, and just like last year, the year before, and 4 years ago, I wanted to end the year off by ranking the 48 most influential free and paid mobile games I have played that were released this year.

So here are all the games. Remember, if you disagree, that’s completely fine. This is naturally a subjective list of the games I have played. Hope you’ll enjoy it – it’s my way of ending off a great year of mobile gaming <3

Video version here: https://youtu.be/ADk6kVtDuvQ

See the image of the final tier list here: https://i.imgur.com/QSr2YM1.jpeg

__________

S-tier Mobile Games of 2024:

A-tier Mobile Games of 2024:

B-tier Mobile Games of 2024:

C-tier Mobile Games of 2024:

D-tier Mobile Games of 2024:

E-tier Mobile Games of 2024:

F-tier Mobile Games of 2024:

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

​r/Android 2024 is coming to an end, and just like last year, the year before, and 4 years ago, I wanted to end the year off by ranking the 48 most influential free and paid mobile games I have played that were released this year. So here are all the games. Remember, if you disagree, that’s completely fine. This is naturally a subjective list of the games I have played. Hope you’ll enjoy it – it’s my way of ending off a great year of mobile gaming <3 Video version here: https://youtu.be/ADk6kVtDuvQ See the image of the final tier list here: https://i.imgur.com/QSr2YM1.jpeg __________ S-tier Mobile Games of 2024: Halls of Torment: Premium – Landscape ($4.99) Google Play MiniReview review Post on AndroidGaming where this was reviewed Ex Astris – Landscape ($9.99) Google Play MiniReview review Post on AndroidGaming where this was reviewed PewPew Live 2 – Landscape ($5.99) Google Play MiniReview review Post on AndroidGaming where this was reviewed Warbits+ – Portrait + Landscape ($4.99) Google Play MiniReview review Post on AndroidGaming where this was reviewed Afterimage – Landscape ($5.99) Google Play MiniReview review Post on AndroidGaming where this was reviewed Balatro – Landscape ($9.99) Google Play MiniReview review Post on AndroidGaming where this was reviewed A-tier Mobile Games of 2024: Valefor: Roguelike Tactics – Landscape (Free Trial) Google Play MiniReview review Post on AndroidGaming where this was reviewed Twilight Survivors – Landscape (Free) Google Play MiniReview review Post on AndroidGaming where this was reviewed Katana ZERO – Landscape (NETFLIX) Google Play MiniReview review Post on AndroidGaming where this was reviewed Art of Rally – Landscape ($7.99) Google Play MiniReview review Post on AndroidGaming where this was reviewed Abalon: Roguelike Tactics CCG – Portrait + Landscape (Free) Google Play MiniReview review Post on AndroidGaming where this was reviewed Born Again Online – Landscape (Free) Google Play MiniReview review Post on AndroidGaming where this was reviewed Waven – Landscape (Free) Google Play MiniReview review Post on AndroidGaming where this was reviewed Star Wars: Hunters – Landscape (Free) Google Play MiniReview review Post on AndroidGaming where this was reviewed Blood Strike – Landscape (Free) Google Play MiniReview review Post on AndroidGaming where this was reviewed Pokémon TCG Pocket – Portrait (Free) Google Play MiniReview review Post on AndroidGaming where this was reviewed Eterspire – Landscape (Free) Google Play MiniReview review Post on AndroidGaming where this was reviewed Wizardry Variants Daphne – Portrait (Free) Google Play MiniReview review Post on AndroidGaming where this was reviewed Dadish 3D – Landscape (Free) Google Play MiniReview review Post on AndroidGaming where this was reviewed Vroomies – Portrait (Free) Google Play MiniReview review Post on AndroidGaming where this was reviewed Zombotron Re-Boot – Landscape (Free) Google Play MiniReview review Post on AndroidGaming where this was reviewed Go Go Muffin – Portrait (Free) Google Play MiniReview review Post on AndroidGaming where this was reviewed B-tier Mobile Games of 2024: Honor of Kings – Landscape (Free) Google Play MiniReview review Post on AndroidGaming where this was reviewed AFK Journey – Portrait (Free) Google Play MiniReview review Post on AndroidGaming where this was reviewed Bloons Card Storm – Landscape (Free) Google Play MiniReview review IdleMMO – Portrait (Free) Google Play MiniReview review Island Times: Easy Life – Portrait (Free) Google Play MiniReview review Post on AndroidGaming where this was reviewed Nerd Survivors – Landscape ($2.99) Google Play MiniReview review Post on AndroidGaming where this was reviewed Auto Pirates: Captain’s Cup – Portrait (Free) Google Play MiniReview review Post on AndroidGaming where this was reviewed Ocean Keeper: Dome Survival – Landscape (Free) Google Play MiniReview review Post on AndroidGaming where this was reviewed Disney Speedstorm – Landscape (Free) Google Play MiniReview review Post on AndroidGaming where this was reviewed Tarisland – Landscape (Free) Google Play MiniReview review Post on AndroidGaming where this was reviewed Zenless Zone Zero – Landscape (Free) Google Play MiniReview review Post on AndroidGaming where this was reviewed Wuthering Waves – Landscape (Free) Google Play MiniReview review Post on AndroidGaming where this was reviewed Call of Duty: Warzone Mobile – Landscape (Free) Google Play MiniReview review Post on AndroidGaming where this was reviewed C-tier Mobile Games of 2024: CookieRun: Tower of Adventures – Landscape (Free) Google Play MiniReview review Post on AndroidGaming where this was reviewed Squad Busters – Landscape (Free) Google Play MiniReview review Post on AndroidGaming where this was reviewed Devil May Cry: Peak of Combat – Landscape (Free) Google Play MiniReview review Post on AndroidGaming where this was reviewed Meow Hunter – Landscape (Free) Google Play MiniReview review Post on AndroidGaming where this was reviewed Earn to Die Rogue – Landscape (Free) Google Play MiniReview review Post on AndroidGaming where this was reviewed D-tier Mobile Games of 2024: Amikin Adventure: Sim RPG – Landscape (Free) Google Play MiniReview review Post on AndroidGaming where this was reviewed Solo Leveling: Arise – Landscape (Free) Google Play MiniReview review Post on AndroidGaming where this was reviewed AXREN – Landscape (Free) Google Play MiniReview review Post on AndroidGaming where this was reviewed E-tier Mobile Games of 2024: Metal Slug: Awakening – Landscape (Free) Google Play MiniReview review Post on AndroidGaming where this was reviewed Invincible: Guarding the Globe – Portrait (Free) Google Play MiniReview review Post on AndroidGaming where this was reviewed F-tier Mobile Games of 2024: Age of Empires Mobile – Landscape (Free) Google Play MiniReview review submitted by /u/NimbleThor [link] [comments] 

2024 is coming to an end, and just like last year, the year before, and 4 years ago, I wanted to end the year off by ranking the 48 most influential free and paid mobile games I have played that were released this year.

So here are all the games. Remember, if you disagree, that’s completely fine. This is naturally a subjective list of the games I have played. Hope you’ll enjoy it – it’s my way of ending off a great year of mobile gaming <3

Video version here: https://youtu.be/ADk6kVtDuvQ

See the image of the final tier list here: https://i.imgur.com/QSr2YM1.jpeg

__________

S-tier Mobile Games of 2024:

A-tier Mobile Games of 2024:

B-tier Mobile Games of 2024:

C-tier Mobile Games of 2024:

D-tier Mobile Games of 2024:

E-tier Mobile Games of 2024:

F-tier Mobile Games of 2024:

submitted by /u/NimbleThor
[link] [comments]  2024 is coming to an end, and just like last year, the year before, and 4 years ago, I wanted to end the year off by ranking the 48 most influential free and paid mobile games I have played that were released this year. So here are all the games. Remember, if you disagree, that’s completely fine. This is naturally a subjective list of the games I have played. Hope you’ll enjoy it – it’s my way of ending off a great year of mobile gaming <3 Video version here: https://youtu.be/ADk6kVtDuvQ See the image of the final tier list here: https://i.imgur.com/QSr2YM1.jpeg __________ S-tier Mobile Games of 2024: Halls of Torment: Premium – Landscape ($4.99) Google Play MiniReview review Post on AndroidGaming where this was reviewed Ex Astris – Landscape ($9.99) Google Play MiniReview review Post on AndroidGaming where this was reviewed PewPew Live 2 – Landscape ($5.99) Google Play MiniReview review Post on AndroidGaming where this was reviewed Warbits+ – Portrait + Landscape ($4.99) Google Play MiniReview review Post on AndroidGaming where this was reviewed Afterimage – Landscape ($5.99) Google Play MiniReview review Post on AndroidGaming where this was reviewed Balatro – Landscape ($9.99) Google Play MiniReview review Post on AndroidGaming where this was reviewed A-tier Mobile Games of 2024: Valefor: Roguelike Tactics – Landscape (Free Trial) Google Play MiniReview review Post on AndroidGaming where this was reviewed Twilight Survivors – Landscape (Free) Google Play MiniReview review Post on AndroidGaming where this was reviewed Katana ZERO – Landscape (NETFLIX) Google Play MiniReview review Post on AndroidGaming where this was reviewed Art of Rally – Landscape ($7.99) Google Play MiniReview review Post on AndroidGaming where this was reviewed Abalon: Roguelike Tactics CCG – Portrait + Landscape (Free) Google Play MiniReview review Post on AndroidGaming where this was reviewed Born Again Online – Landscape (Free) Google Play MiniReview review Post on AndroidGaming where this was reviewed Waven – Landscape (Free) Google Play MiniReview review Post on AndroidGaming where this was reviewed Star Wars: Hunters – Landscape (Free) Google Play MiniReview review Post on AndroidGaming where this was reviewed Blood Strike – Landscape (Free) Google Play MiniReview review Post on AndroidGaming where this was reviewed Pokémon TCG Pocket – Portrait (Free) Google Play MiniReview review Post on AndroidGaming where this was reviewed Eterspire – Landscape (Free) Google Play MiniReview review Post on AndroidGaming where this was reviewed Wizardry Variants Daphne – Portrait (Free) Google Play MiniReview review Post on AndroidGaming where this was reviewed Dadish 3D – Landscape (Free) Google Play MiniReview review Post on AndroidGaming where this was reviewed Vroomies – Portrait (Free) Google Play MiniReview review Post on AndroidGaming where this was reviewed Zombotron Re-Boot – Landscape (Free) Google Play MiniReview review Post on AndroidGaming where this was reviewed Go Go Muffin – Portrait (Free) Google Play MiniReview review Post on AndroidGaming where this was reviewed B-tier Mobile Games of 2024: Honor of Kings – Landscape (Free) Google Play MiniReview review Post on AndroidGaming where this was reviewed AFK Journey – Portrait (Free) Google Play MiniReview review Post on AndroidGaming where this was reviewed Bloons Card Storm – Landscape (Free) Google Play MiniReview review IdleMMO – Portrait (Free) Google Play MiniReview review Island Times: Easy Life – Portrait (Free) Google Play MiniReview review Post on AndroidGaming where this was reviewed Nerd Survivors – Landscape ($2.99) Google Play MiniReview review Post on AndroidGaming where this was reviewed Auto Pirates: Captain’s Cup – Portrait (Free) Google Play MiniReview review Post on AndroidGaming where this was reviewed Ocean Keeper: Dome Survival – Landscape (Free) Google Play MiniReview review Post on AndroidGaming where this was reviewed Disney Speedstorm – Landscape (Free) Google Play MiniReview review Post on AndroidGaming where this was reviewed Tarisland – Landscape (Free) Google Play MiniReview review Post on AndroidGaming where this was reviewed Zenless Zone Zero – Landscape (Free) Google Play MiniReview review Post on AndroidGaming where this was reviewed Wuthering Waves – Landscape (Free) Google Play MiniReview review Post on AndroidGaming where this was reviewed Call of Duty: Warzone Mobile – Landscape (Free) Google Play MiniReview review Post on AndroidGaming where this was reviewed C-tier Mobile Games of 2024: CookieRun: Tower of Adventures – Landscape (Free) Google Play MiniReview review Post on AndroidGaming where this was reviewed Squad Busters – Landscape (Free) Google Play MiniReview review Post on AndroidGaming where this was reviewed Devil May Cry: Peak of Combat – Landscape (Free) Google Play MiniReview review Post on AndroidGaming where this was reviewed Meow Hunter – Landscape (Free) Google Play MiniReview review Post on AndroidGaming where this was reviewed Earn to Die Rogue – Landscape (Free) Google Play MiniReview review Post on AndroidGaming where this was reviewed D-tier Mobile Games of 2024: Amikin Adventure: Sim RPG – Landscape (Free) Google Play MiniReview review Post on AndroidGaming where this was reviewed Solo Leveling: Arise – Landscape (Free) Google Play MiniReview review Post on AndroidGaming where this was reviewed AXREN – Landscape (Free) Google Play MiniReview review Post on AndroidGaming where this was reviewed E-tier Mobile Games of 2024: Metal Slug: Awakening – Landscape (Free) Google Play MiniReview review Post on AndroidGaming where this was reviewed Invincible: Guarding the Globe – Portrait (Free) Google Play MiniReview review Post on AndroidGaming where this was reviewed F-tier Mobile Games of 2024: Age of Empires Mobile – Landscape (Free) Google Play MiniReview review submitted by /u/NimbleThor [link] [comments]

Read more

Alternatives to sqlite3 for making .db files? /u/Pademel0n Python Education

Alternatives to sqlite3 for making .db files? /u/Pademel0n Python Education

Hi I’ve been using sqlite3 in a python script to create .db files from some data dumps I have. But due to file size of my data sources I have had to move to remote storage, this is incompatible with sqlite3 unfortunately and will result in an error claiming “database is locked”.

After a quick search, alternatives like Postgres just seem a bit bigger scale than the simple feature I want, I don’t want to have to set up separate servers or anything.

Does anyone have recommendations?

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

​r/learnpython Hi I’ve been using sqlite3 in a python script to create .db files from some data dumps I have. But due to file size of my data sources I have had to move to remote storage, this is incompatible with sqlite3 unfortunately and will result in an error claiming “database is locked”. After a quick search, alternatives like Postgres just seem a bit bigger scale than the simple feature I want, I don’t want to have to set up separate servers or anything. Does anyone have recommendations? submitted by /u/Pademel0n [link] [comments] 

Hi I’ve been using sqlite3 in a python script to create .db files from some data dumps I have. But due to file size of my data sources I have had to move to remote storage, this is incompatible with sqlite3 unfortunately and will result in an error claiming “database is locked”.

After a quick search, alternatives like Postgres just seem a bit bigger scale than the simple feature I want, I don’t want to have to set up separate servers or anything.

Does anyone have recommendations?

submitted by /u/Pademel0n
[link] [comments]  Hi I’ve been using sqlite3 in a python script to create .db files from some data dumps I have. But due to file size of my data sources I have had to move to remote storage, this is incompatible with sqlite3 unfortunately and will result in an error claiming “database is locked”. After a quick search, alternatives like Postgres just seem a bit bigger scale than the simple feature I want, I don’t want to have to set up separate servers or anything. Does anyone have recommendations? submitted by /u/Pademel0n [link] [comments]

Read more

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