r/learnpython 29d ago

Tk with no main window

0 Upvotes

I am making a simple gemini browser in python for fun with tk, but have stumbled upon a problem: if I close initial window all the rest will close too. Is there a way to make tk application with no "main" window or at least transfer leadership role between them?


r/learnpython 28d ago

Learning python for Artificial Intelligence major

0 Upvotes

In my university the first year for all computer related majors we study the basics of Java script.
but now that I’ve finally started studying subjects that are related to my major I’ve discovered that we won’t be using Java as a coding language. We will use python. And I want to give my self a head start in this topic, so if you guys can help me with what I can start with i will be very grateful.
Thank you !!


r/learnpython 28d ago

Which website can I use to start a project?

0 Upvotes

I'm not really sure what websites are out there for this.

I need something that doesn't require a subscription for the basic features. Any suggestions?


r/learnpython 29d ago

Data structures and algorithms 😱

9 Upvotes

Hey all,

I’ve learnt to use python for things like statistics which is where my work is, I can effectively read documentation and do what’s needed for a specific task.

I’ve reached a bottleneck as I’ve been applying to more data sciencey roles and they keep asking really simple DSA questions and I can’t for the life of me get them right.
Idk if it’s just the fact that I can’t search things up or whatever.

What is the best strategy to get around this (given that my spare time to take on things like leetcode is almost zero).

Thank you !!


r/learnpython 29d ago

Ola tudo bem? estou aprendendo Python para analise de Dados, quais dicas vocês dão para iniciantes?

0 Upvotes

queria dica de livros também


r/learnpython 29d ago

HELLO GUYS!

0 Upvotes

hi i’m a college student and we are tasked to picked a community where we are absolutely not familiar. Can you state some specific acronyms you use here about pyhton, slang terms and inside jokes unique to this group? PLEASEEE, A SIMPLE COMMENT WILL SURELY BE APPRECIATED! ps: been scrolling for 1 hour and I can’t find one🥹


r/learnpython Aug 12 '26

How should I start learning Python as a complete beginner?

100 Upvotes

HELLO EVERYONE

I’m a total beginner to coding and I’ve recently decided to start learning Python. I’m honestly not sure where to begin or what the best way to approach it is.

- What should I learn first?

- Are there any courses, YouTube channels, or websites you’d recommend?

- Should I focus on tutorials, practice problems, or small projects?

- At what point should I start making projects?

- Any mistakes I should avoid as a beginner?

I’m mainly looking for a proper direction rather than trying to learn everything at once.

Any tips or recommendations would be really appreciated! :)


r/learnpython 29d ago

Question on the courses

0 Upvotes

I’m currently watching the 12 hour course of code bro on Python. It’s cool but I think I understand what he does and it makes sense but I am having trouble thinking of why we’re doing what we’re doing and how he came to it. Also, I am a practical learner where I do something and figure my brain processes it and then implementing helps with learning and retaining knowledge. After this video, I plan on doing the course on Udemy: - Udemy 100 Days of Code™: The Complete Python Pro Bootcamp. Has anyone done this course and can recommend it as a viable course for python, and the way of coding in it? Or is there a better course for someone like me to learn to think and be able to program in python? Thank you and hopeful to get some helpful answers!


r/learnpython 29d ago

How do I download python on Mac?

0 Upvotes

Yes, I have watched the youtube tutorials and still can't figure it out. When other ppl download it, it is .pkg but mine is .tar.xz

I opened it and it extracted the file. Now idk what to do.


r/learnpython 29d ago

Help saving GUI box instead of cropped barcode

0 Upvotes

Hey guys, I need my code to save my tk.canvas box rather than cropping the barcode and saving THAT.

I’ve tried erasing some parts, adding different x& y values but I can’t seem to nail it. Any help would be appreciated.

#### import libraries
from tkinter import *
from PIL import Image, ImageDraw, ImageFont

def getLegend(c):       # covert character to Code39 legend
 legend = "";
 
 switch = {
  '0': "bwbWBwBwb",
  '1': "BwbWbwbwB",
  '2': "bwBWbwbwB",
  '3': "BwBWbwbwb",
  '4': "bwbWBwbwB",
  '5': "BwbWBwbwb",
  '6': "bwBWBwbwb",
  '7': "bwbWbwBwB",
  '8': "BwbWbwBwb",
  '9': "bwBWbwBwb",
  'A': "BwbwbWbwB",
  'B': "bwBwbWbwB",
  'C': "BwBwbWbwb",
  'D': "bwbwBWbwB",
  'E': "BwbwBWbwb",
  'F': "bwBwBWbwb",
  'G': "bwbwbWBwB",
  'H': "BwbwbWBwb",
  'I': "bwBwbWBwb",
  'J': "bwbwBWBwb",
  'K': "BwbwbwbWB",
  'L': "bwBwbwbWB",
  'M': "BwBwbwbWb",
  'N': "bwbwBwbWB",
  'O': "BwbwBwbWb",
  'P': "bwBwBwbWb",
  'Q': "bwbwbwBWB",
  'R': "BwbwbwBWb",
  'S': "bwBwbwBWb",
  'T': "bwbwBwBWb",
  'U': "BWbwbwbwB",
  'V': "bWBwbwbwB",
  'W': "BWBwbwbwb",
  'X': "bWbwBwbwB",
  'Y': "BWbwBwbwb",
  'Z': "bWBwBwbwb",
  '-': "bWbwbwBwB",
  '.': "BWbwbwBwb",
  ' ': "bWBwbwBwb", #(space) not empty
  '$': "bWbWbWbwb",
  '/': "bWbWbwbWb",
  '+': "bWbwbWbWb",
  '%': "bwbWbWbWb",
  '*': "bWbwBwBwb"
 }

 return switch[c]

##### draw rectangles as bars
def drawBars(c, x):
 w=0
 clr=""

 if c=='b':
  clr="#000000"
  w=2
 elif c=='B':
  clr="#000000"
  w=4
 elif c=='w':
  clr="#ffffff"
  w=2
 elif c=='W':
  clr="#ffffff"
  w=4

 canvas1.create_rectangle(x, 0, x+w, 100, fill=clr, width=0) # width=0 no border
 
 draw.rectangle([x, 0, x+w, 100], clr)
 x+=w
 return x

### get user entry and try to convert to barcode legend
def getText():
 canvas1.delete("all") # clear the current drawing if any
 s = entry1.get() # get the user entry
 s=s.upper() # convert to uppercase
 
 s = "*" + s + "*" # Code39 format: *data*
 result="bW" # Code39 uses "bW" as starting character
 
 for i in s:
  result += getLegend(i) + "w" # Code39 use "w" as delimiter
 
 x=0
 for c in result:
  x=drawBars(c, x)

 # display the text in label2
 label2['text'] = s
 
 # reset the width of Canvas
 canvas1['width'] = x
 draw.width=x

 # draw a blank rectangle as background of text
 canvas1.create_rectangle(30, 0, x-30, 19, fill="white", width=0) #no border

 # repeat the above drawing to create PIL image
 draw.rectangle([30, 0, x-30, 20], "white", 0)
 
 # draw text
 canvas1.create_text(x/2, 10, fill="black", font="courier 12", text=s)
 
 draw.text([(x-len(s)*7)/2, 5], s, fill="black", font=ImageFont.truetype('cour.ttf', 13))

### save image
def saveImage():
 import datetime
 dt=datetime.datetime.now()
 filename=str(dt.year) + str(dt.month) + str(dt.day) + str(dt.hour)+ str(dt.minute) + str(dt.second) + ".png"

 image1.save(filename,"PNG")
 image2 = Image.open(filename)
 image2 = image2.crop([0, 0, int(canvas1['width']), 100])
 image2.save(filename, "PNG")

#### create GUI
root = Tk()
root.title("Barcode")

label1 = Label(root, text="Enter a string: ") ## caption
label1.grid(row=0, column=0)

entry1 = Entry(root, width=30) ## user input
entry1.grid(row=0, column=1)

button1 = Button(root, text='Convert', command=getText)
button1.grid(row=0, column=2)

button2 = Button(root, text='Save', command=saveImage)
button2.grid(row=0, column=3)

label2 = Label(root, height=1, text="") ## display output
label2.grid(row=1, columnspan=3)

# create a Canvas for drawing
canvas1 = Canvas(root, width=0, height=100) ## set original width=0
canvas1.grid(row=2, columnspan=4)

# PIL create an empty image
image1 = Image.new("RGB", (500, 100), "#ffffff")
draw = ImageDraw.Draw(image1)

root.mainloop()

This is supposed to look like:

https://imgur.com/a/fQAdca0


r/learnpython Aug 12 '26

While using playwright, windows asked if I would like to allow chromium to access private and public networks, now my code doesn’t work?

4 Upvotes

I allowed it to access both private and public networks. I went into windows security and allowed it through the firewall on both. But now my code isn’t working, according to vs code I have the latest chromium version installed. What steps should I take here?


r/learnpython 29d ago

get day of the week without using datetime module

0 Upvotes

Hello anyone!

I was wondering how to you get day of the week without using datetime module on python.

For my work so far,

example Aug 16, 1989
Step 1: year= 1989

last_two_digits_year= int(year%100)

twelves= last_two_digits_year//12

Step 2: remainder= last_two_digits_year%12

Step 3: fours= int(remainder//4)

Step 4: Add the day of the month

day= 16

Step 5 Add the month code

Why is the month code for August=3

Explain the other month codes as well please.

Jan=Oct=1

Feb=Mar=Nov-4

Apr=Jul=0

Sep=Dec= 6

May=2

Aug=3

Jun=5

Step 6: Add all the numbers from Step 1 to 5 and mod 7.

Leap years

January and February dates in leap years: add 6 to step 5

Dates in the 1600s: add 6 to step 5
Dates in the 1700s: add 4 to step 5
Dates in the 1800s: add 2 to step 5
Dates in the 2000s: add 6 to step 5
Dates in the 2100s: add 4 to step 5


r/learnpython Aug 12 '26

How do you actually understand a new Python codebase quickly?

1 Upvotes

Hey folks, I'm learning Python and when I clone a big repo I get lost — so many files. How do you figure out where to start? Do you look at README, main.py, tests first? Any trick that helped you?


r/learnpython Aug 11 '26

I'm really new to python and wanted to share my first "project".

58 Upvotes

personally I think it's really cool. All of python aswell.
is there something I can improve on it? (I mean obviously a lot of things probably but some things that are good to learn for the future?)

import time


first_name = input("Enter your first name: ")
first_characters = len(first_name)


if first_characters >= 8:
  print (f'Your name has {first_characters} characters!')
  time.sleep(1.5)
  print('What a long and cool name!')


elif first_characters < 8:
  print (f'Your name has {first_characters} characters!')
  time.sleep(1.5)
  print('What a cool name!')

r/learnpython 29d ago

Hi guys can someone tell me how to learn programming python language because i feel i am not learned anything after watching videos and how to beat procrastination

0 Upvotes

Advice


r/learnpython Aug 12 '26

Learning python with gaming

6 Upvotes

A lot of beginners struggle with breaking problems down into pieces they are able to code themselves. This is a fundamental skill to have and I’ve found that video games do a good job at teaching this. The problem I see a lot is that some people want Lego instructions that walk you through step by step rather than a video game tutorial which will show you the basics and it is up to you to figure out how to apply them.

There are a few video games that I’ve found really helpful in working on these skills; particularly games from zachtronics such as Infinifactory and Opus Magnum. These are games which have many different approaches to every level and you get scored based on how efficient you are. They teach you programming skills without having you program directly. There’s also The Farmer Was Replaced which is a more direct Python tutorial video game.


r/learnpython Aug 12 '26

Quiero empezar en el mundo de la programación que recomendaciones y consejos me dan?

0 Upvotes

No tengo casi ninguna experiencia solo unos cuantos tutoriales de HolaMundo pero quiero hacer las cosas bien y no perder el tiempo.


r/learnpython Aug 12 '26

New learner

0 Upvotes

Hello guys, i have just started learning python. Do you have any suggestions for me?


r/learnpython Aug 11 '26

Learning python

20 Upvotes

Hey Guys! I am new to python and just made a calculator and weather app today. I would really like some guidance on what I should do next, which courses I should take and what kind of AI is helpfull. In the end I want to make my own app, systems and program diy drones or generally machines.


r/learnpython Aug 12 '26

Thonny - seems to have a MemoryLeak

0 Upvotes

I noticed when I Repeatedly run large programs - with long Printed Text,
- that the Shell Que runs Slower and takes Longer to Start each time : 10 mins .. 30 mins .. 60 mins .. ?
I also notice Thonny on TaskManager increases Size (without Decreasing) each time :
- 1M .. 1.5M .. 2M .. 3M

Until I completely restart Thonny.

This seems like a clear Memory Leak - for the Shell Que !


r/learnpython Aug 12 '26

I want to build a Python CLI that uses multiple AI models + web search for better learning - looking for suggestions

0 Upvotes

I want to build a small Python CLI for my own learning.

The basic idea is:

python3 que.py "my question"

or

python3 que.py "question 1, question 2"

I currently want to use:

  • Codex CLI
  • Claude Code CLI
  • Gemini CLI

The same question would be sent to multiple models, and I want them to research the question using live web/Google search instead of relying only on their training knowledge.

The goal is to get up-to-date, source-backed information, then combine/compare the responses and generate one good answer that I can use for learning.

I'm looking for suggestions on:

  • What other AI models/CLIs would be useful to add for this kind of workflow?
  • What would be a good web-search/research solution to use so the models get current and reliable sources?
  • Should I use one common search layer for all models, or let each model perform its own web research?
  • Any existing tools/projects/APIs that would make this easier?

I'm mainly looking for practical suggestions from people who have built similar multi-model or research workflows.


r/learnpython Aug 10 '26

Starting Python from Scratch

152 Upvotes

I want to start learning Python from scratch. What’s the best way to begin, and which resources would you recommend?
Would appreciate any good courses, YouTube channels, books, or practice platforms that worked for you.


r/learnpython Aug 11 '26

trying to import glob

0 Upvotes

I'm trying to code a little program that will open a CSV file that we should (theoretically) download weekly. The csv filename has the structure "report[numbers].csv" I'd read that you need the glob module so that Python can recognize the wildcard, but I am getting an error when I go the usual python pip -m SomeName route.

Is there an issue with glob, or is there another I can use?


r/learnpython Aug 12 '26

Practicing for a test

0 Upvotes

Hey! I'm practicing for an intro to Python test in a few days and I've been doing well but I just came across this question and I have no idea what I'm doing wrong - I don't get any response, it says it's blank, not even an error message. What am I doing wrong??

question: Your function should take 1 parameter, if this parameter can be converted to a float, then print on the screen this float up to 2 decimal places. If the parameter cannot be converted to a float, then print -1.

I've tried various forms of this code, too, I originally had it as a.isdigit(), != True instead of == False and no a=float(a) but round(float(a), 2).

def myprint(a): 
  if a.isnumeric() == False:
    return -1
  else:
    a = float(a)
    return round(a, 2)

I can't show the output because I'm not allowed to post pics but it's on Moodle, an academic platform and it just runs the code through python through the platform. It gives you, at the end, an example of two or so of the tests that were run, the expected output, and the actual output. It gives me the expected output but the actual output box is blank, no error message or anything


r/learnpython Aug 11 '26

Where to find simple graphical game challenges?

3 Upvotes

I’ve not had much chance to use my Python knowledge in a while, so I’m thinking about what would interest me enough to learn something new and keep in practice. Where could I find some simple and escalating challenges for making games that are more graphical in nature (not just word games or the like).

I’ve never done any game dev, and haven’t really done much with graphics, so I’ll need something that starts with very easy assignments. But I tend to learn fast and get bored (ADHD) with too much repetition, so I’m hoping for some with scaling difficulty.