Press J to jump to the feed. Press question mark to learn the rest of the keyboard shortcuts
Moderator of r/learnpythonStickied post

Welcome to another r/learnPython weekly "Ask Anything* Monday" thread

Here you can ask all the questions that you wanted to ask but didn't feel like making a new thread.

* It's primarily intended for simple questions but as long as it's about python it's allowed.

If you have any suggestions or questions about this thread use the message the moderators button in the sidebar.


  • Don't downvote stuff - instead explain what's wrong with the comment, if it's against the rules "report" it and it will be dealt with.

  • Don't post stuff that doesn't have absolutely anything to do with python.

  • Don't make fun of someone for not knowing something, insult anyone etc - this will result in an immediate ban.

That's it.


Does anybody have any recommended sites for learning python that have projects that start out easy with increasing complexity where it goes step by step through making a functioning program and how each used piece of code works together. I'm going through an online course where I have learned bits and pieces of code and what they do but not really sure how to put it all together yet or does that become more obvious the more I learn?


I've tried very hard with TKinter but I just really dislike using it.

I love python's syntax for everything that is not GUI based but TKInter just looks nothing like python. I don't understand why deleting something in a text area (Via a function) requires a string as an argument or ignores basic python conveniences like the SUUPER simple [:-1] for example.

Is there any other libraries that feel a little more.... Pythony? Or should I just grin and bear it until TKinter actually makes sense?


It feels kind of repetitive and unaesthetic to add so many.


I created a web app with flask that stores sensitive user data in a database. I now want to protect this dldata in case someone hacks into my server. My current approach is using gpg to encrypt each cell in the database that is sensitive (e.g. email, name, address). To decrypt it, a password has to be provided that unlocks the private key.

However, this approach is quite computation intensive and the data is getting bigger due to the asymmetric encryption, so I was wondering if there are better approaches?

EDIT: I want users to enter sensitive data, and after it has been entered I should be the only one to be able to read it. So I can not encrypt the data with the users password.

I can also not use symmetrical encryption, as the code and the database will be stored on the same server.

def yg(d, a):
    return str(d) + str(a)
np.apply_along_axis(yg, 1, np.array([1, 2, 3, 4]), "h")

The output should be ["1h" "2h" "3h" "4h"], or something like that.

Putting 1 made an error, and putting 0 made it "[1,2,3,4]h"

1 comment

I tried making the first border around my image using loops but it keeps showing an error, here is my code.

from PIL import Image
pct = int(input("What percent should the border be? "))/100
img ="something.jpg")

width = img.size[0]
height = img.size[1]

for x in range(width):
    for y in range(height):
    r,g,b = img.putpixel((x,y))

    if x < width * pct:
       r = g = h = 255
    if x > width *(1-pct):
       r = g = h = 255
    if y < height * pct:
       r = g = h = 255
    if y > height * (1-pct):

I have been working on this program for a couple weeks while learning. It utilizes the cryptography library and encrypts/decrypts password data. Then it prints that data into a multi listbox. This is the first program I've made using classes.

I separated the first part of the program called "init_program" which checks for an existing key and verifies that a given password matches the same password that was provided to make that key. I will likely end up combining this into the main program somehow.

Anyway, heres the code:


Community Details





Oct 2, 2009

Cake Day

Subreddit for posting questions and asking for general advice about your python code.

r/learnpython Rules

Posting only the project goal is not allowed.
Be polite.
Read the wiki for answers to common questions.
Don't ask easily searchable questions.

Code Hosting/Formatting

Post your code on these websites and include the link in your thread, or click on the button below to find out how to properly format code and include it in your submission text.

Helpful posting resources

Please check out few of these links to see how to properly ask a software development related questions.

Related Subreddits


454k members


61.0k members


24.0k members


2.3m members


1.2m members


194k members

Commenting Guidelines

  • Try to guide OP to a solution instead of providing one directly.

  • Provide links to related resources.

  • Answer the question and highlight side-issues if any exist.

  • Don't "answer and run", be prepared to respond to follow up questions.

  • Proofread your answers for clarity and correctness.

  • Be polite.

Posting Guidelines

  • Try out suggestions you get and report back.

  • SSCCE Keep your code Short, Self Contained, Correct (Compilable) and provide Example

  • Include the error you get when running the code, if there is one.

  • Ensure your example is correct. Either the example compiles cleanly, or causes the exact error message about which you want help.

  • Avoid posting a lot of code in your posts.

  • Posting homework assignments is not prohibited if you show that you tried to solve it yourself.

Cookies help us deliver our Services. By using our Services or clicking I agree, you agree to our use of cookies. Learn More.
RedditView is Reddit Online Viewer ,Not Phising ,Not Hacking!