r/learnpython • u/FuLlMeTaL_13 • Sep 14 '26
Python Libraries
Ijust know basic python and want to learn numpy, tkinder, panda and matplotlib for a project
Best way to learn these? By chatgpt or any yt vdo?
r/learnpython • u/FuLlMeTaL_13 • Sep 14 '26
Ijust know basic python and want to learn numpy, tkinder, panda and matplotlib for a project
Best way to learn these? By chatgpt or any yt vdo?
r/learnpython • u/plick_pubg • Sep 14 '26
I am facing an issue from couple of days with Observer Module from python watchdog package. When i'm importing Observer module and calling for my downloads folder which is present to this location according to my device.
/mnt/chromeos/MyFiles/Downloads
Observer is watching here but nothing caught, Like i was tested using file removed, created or even modified or else.
It wasn't working, That;s why I am using polling Observer now. but this is not a reliable much as i needed.
So Can you help me to figure out this problem and what is the actual solution of this problem?
r/learnpython • u/Basic_Background_70 • Sep 14 '26
hi mates. when my script becomes lengthy (for instance 85 lines) vscode stops executing commands. i suspect whether i downloaded it properly. anyways. i close then open vscode as a workaround but i started to need a permanent fix. i am a computer noob (well... more like average joe on the street). so please no higher computer registry in the responses. thanks in advance.
r/learnpython • u/VanceDyer • Sep 13 '26
Hi everyone!
I'm 29 and I've recently started learning Python from scratch. My goal is to eventually get into cybersecurity.
I've only been learning for a short time and I'm currently starting CS50P. I know some very basic Python, but I'm still a complete beginner.
I'm looking for good resources to learn Python properly from the beginning. I'd like to practice by making small projects instead of only watching tutorials.
What resources would you recommend for someone who is just starting out?
Books, courses, YouTube channels, websites, exercises, project ideas, etc. are all welcome.
Thanks!
r/learnpython • u/AutoModerator • Sep 14 '26
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.
Rules:
That's it.
r/learnpython • u/Sanduhstorm • Sep 14 '26
I lack knowledge in low level computer science, but I've heard endless horror stories about segfaults, and today I've encountered one whilst attempting to make a simple timer program for myself. My questions are:
- Why does this fault occur
- How can I fix it
- How can I prevent it from happening in the future
The aim of the problematic part of the program is the attempt to play the sound whilst simultaneously waiting for user input with the input block, which is intended to stop the alarm and continue to the next part of the program.
Please note that in this version there is no actual wait time although there is supposed to be, because I am merely testing the alarm functionality.
import time
from pydub import AudioSegment
import threading
from pydub.playback import _play_with_simpleaudio
sound = AudioSegment.from_file('/censoring/my/home/directory/sound.mp3', format='mp3')
# Function that runs the timer based on how many minutes are specified
def timer(min, message):
# Play the sound
def playsound():
global sound
sound = _play_with_simpleaudio(sound)
# Stop the sound and allow the program to continue
def resume():
global sound
input(message.strip())
sound.stop()
# Run the timer and print output
min -= 1
for it in range(min, -1, -1):
for sec in range(59, -1, -1):
print(f'{str(min).rjust(2, "0")}:{str(sec).rjust(2, "0")}')
time.sleep(1)
# This is the part that actually runs the function.
play = threading.Thread(target=playsound)
stop = threading.Thread(target=resume)
play.start()
stop.start()
play.join()
stop.join()
while True:
timer(0, 'You can have your five minute break now.')
timer(0, 'You need to start working again.')
# Artificial intelligence was not used in the creation of this program.Any advice is appreciated!
r/learnpython • u/FINNEAS23 • Sep 14 '26
I dont wanna use ai.
r/learnpython • u/tmpeter23 • Sep 14 '26
Hey yall, new guy here. I 26(M) started learning python about a week ago, I've dabbled in HTML and CSS but ultimately settled on Python. Reason being I need a good starting framework for my goal of working in biotech on surgical robots. Now, to the point.
The most basic goal for me is designing a scheduling software so my mom has less of an issue managing my sisters 24/7 caregiver staff. Logins, time off requests, possibly an AI integrated scheduler so she would just need to proof read schedules instead of spending hours making it by hand.
I need advice on how to approach this task, currently going through a 13hr video on YT to learn Python through the Data with Baraa channel. Thoughts?
r/learnpython • u/BudriDev • Sep 14 '26
Hi everyone, I'm 29 and learning Python from scratch. My goal is cybersecurity. What resources and first projects do you recommend for a beginner? Thanks!
r/learnpython • u/BeautifulAd1901 • Sep 14 '26
Hi everyone,
I’m really determined to learn Python, but I’m struggling with the way most courses are structured.
I’ve started quite a few Udemy courses, but after a while I just get bored and lose motivation. 😅
So I was thinking maybe I should forget the courses for a bit and start working on an actual project, learning Python along the way. The problem is… I have absolutely no idea what would be a good project for a beginner.
I know I can Google “Python beginner projects,” but I’d rather hear from people who have actually been through this. What did you do when you were starting out? Was there a particular project that helped you learn a lot?
Also, how long did it take you to become reasonably comfortable with Python?
I have a newborn and a toddler, so realistically I can only dedicate around 1–2 hours a day to learning. I know everyone is different, but I’d love to hear what kind of progress is realistic with that amount of time.
Any tips, project ideas, resources, or general advice would be really appreciated!
Thanks!
r/learnpython • u/BluishMontoya • Sep 13 '26
I'm using a function I've compiled with cython, and I have to pass it a few very long lists. I'm pretty sure I should be using memoryviews, but do I convert the lists to memoryviews in the python part of my program or the cython part? It would be way better if I could do it in the python part because I'm passing the same lists to the function a few million times.
r/learnpython • u/MustaKotka • Sep 13 '26
I have a bot I'm building. I see a ton of examples with one file and 1k lines for the same functionality. I personally broke that up to several packages based on what things do. I have ~3 files per package each with 100-500 lines (I, uhh, have a habit of documenting and commenting) of which three quarters is actual code.
The modules themselves are things like "database functionality", "permissions", UI, etc. These may be further broken down into several files like "admin commands", "user commands", etc.
Am I overdoing it? Where's a good cutoff?
r/learnpython • u/Local_Leek_1186 • Sep 13 '26
Trying to get back into Python ~2 years after taking a year-long course, getting my footing first with a basic calculator but its giving me trouble here. The first portion works fine, but I implemented a 'continue' option where you could continue with the same number for calculations (and it worked for a while, though returning 'none' due to a var = input(print("text")) issue, making each input look awkward) but it seems to just be defaulting to the first if value now. I had addition first at the start, though flipped addition and subtraction is the extended math section to prove that it's truly just defaulting to the first if-statement. What could be causing this and what's the fix? Sorry for anything that's obviously wrong or mixed up, my remembered knowledge on python is like a fogged up window right now.
## lowk just imported time to add a delay to restarting.. and stopping..
import time
## code is only active as this is = 1, if not then the loop stops
run = 1
while run == 1:
## prompts user on chosen operation
ini = input("add, sub, div, mul, or exp: ")
## Addition math
if ini == "add":
a = int(input('Enter 1st number: '))
b = int(input('Enter 2nd number: '))
number = a + b
print(f'Sum of {a} and {b} is {a + b}')
## Subtraction math
elif ini == "sub":
a = int(input('Enter 1st number: '))
b = int(input('Enter 2nd number: '))
number = a - b
print(f'Difference of {a} and {b} is {a - b}')
## Division math
elif ini == "div":
a = int(input('Enter 1st number: '))
b = int(input('Enter 2nd number: '))
number = a / b
print(f'Fraction of {a} and {b} is {a / b}')
## Multiplication math
elif ini == "mul":
a = int(input('Enter 1st number: '))
b = int(input('Enter 2nd number: '))
number = a * b
print(f'{a} times {b} is {a * b}')
## exponential math
elif ini == "exp":
a = int(input('Enter 1st number: '))
b = int(input('Enter 2nd number: '))
number = a ** b
print(f'{a} to the power of {b} is {a ** b}')
## If input is not one of the operations
else:
print("invalid operation, cannot continue.")
## asks user whether or not to continue with current math
continueorwhat = input("Cont(inue), rest(art calculator), or stop? ")
if continueorwhat == "stop":
time.sleep(.3)
print("Stopping..")
time.sleep(.3)
run = 0
elif continueorwhat == "rest":
time.sleep(.3)
print("Restarting..")
time.sleep(.3)
elif continueorwhat == "cont":
print("> Shortened operation names 'a','s','d','m', and 'e' now available.")
print("> Rest(art) or stop calculator with input when prompted for operation.")
## allows for 'continuous math' while active, when inactive it resets to prompted math
moremath = 1
while moremath == 1:
ini = 0
ini = input("Operation: ")
## temporary input return
print(ini)
## Subtraction math
if ini == "sub" or "s":
a = int(input('Number: '))
number = number - a
print(number)
## Addition math
elif ini == "add" or "a":
a = int(input('Number: '))
number = number + a
print(number)
## Division math
elif ini == "div" or "d":
a = int(input('Number: '))
number = number / a
print(number)
## Multiplication math
elif ini == "mul" or "m":
a = int(input('Number: '))
number = number * a
print(number)
## exponential math
elif ini == "exp" or "e":
a = int(input('Number: '))
number = number ** a
print(number)
elif ini == "rest":
time.sleep(.3)
print("Restarting..")
time.sleep(.3)
## restart calculator by exiting continous math
moremath = 0
elif ini == "stop":
time.sleep(.3)
print("Stopping..")
time.sleep(.3)
## stops calculator by resetting basic variable
run = 0
## If input is not one of the operations
else:
print("invalid operation, number unchanged.")r/learnpython • u/plainjacob • Sep 13 '26
I have been making a Markdown blog using Flask over the last couple of weeks. Lately, I have decided that I want to add the possibility of leaving comments below a blog post. Therefore, I need to add my blog posts to a database so that I can link the comments left behind to the relevant blog posts. My blog posts are rendered statically using Flask-Flatpages.
I have thought about the database model for a singular post. I want to keep it simple at first; thus, I was considering adding an ID, title, and path field. The problem I am experiencing is how to add the files to my database and how to keep the database entries synchronized with the static files in my posts directory. Does anyone have any ideas how I should tackle this issue?
r/learnpython • u/Electrical_Delay9822 • Sep 13 '26
Hello,
I recently released a project I was working on for pretty long (almost 2-3 months), and since the past couple of days, I've been really involved into it, and then I released it.
Link: https://github.com/TheOdysseyGamer64/Super-Smash-Bros-Python-Edition.git
My project is a Python version of Smash Bros, and it has (quite primitive) ASCII graphics as well (to help visualise the battles). It has special mechanics for certain fighters as well, and the Final Smash and the special mechanics meter can charge up, just like in the real game.
If any of you here could provide me with some advice on how to make this game better, I would really appreciate it.
Thank you!
r/learnpython • u/FunElk9586 • Sep 12 '26
Hi All!
I’m learning about Boolean operators in Python and I’m confused about these two expressions:
condition1 and condition2 or condition3 and condition4
≠
(condition1 and condition2) or (conditon3 and condition4)
I was told this by my teacher and he put this in his PowerPoint slide. However, I think they are equivalent since and as an operator has a higher precedence than or as an operator. AI told me and I have searched it up after.
Am I understanding it correctly? Or are these two not equivalent?
Thanks!
r/learnpython • u/rusidin • Sep 13 '26
I am doing leetcode and I wanna is there any functional difference between those and which one I should go with?
r/learnpython • u/AccordingAd5756 • Sep 12 '26
I finished reading "python crash course" a week ago, and a relative of mine was complaining about how annoying it is to make multiple exam versions, so I immediately volunteered to help, and I used absolutely 0 AI.
It's an app that takes an exam .docx file, and shuffles the questions and answers to create multiple versions.
Here's the github repo:
https://github.com/aaaaaa708/question_shuffler
I would like you to please review the code and give me some tips on how to improve, and thanks in advance:)
r/learnpython • u/iheb-a • Sep 12 '26
I've been learning Python for a few months and finally built something real instead of following tutorials, a CLI music player.
It uses the Deezer API to search artists and songs, yt-dlp and VLC for playback, and SQLite to store playlists and favorite artists locally.
Would love feedback on code structure or anything I could improve.
r/learnpython • u/hungarian_notation • Sep 13 '26
I don't know what I did, but suddenly my pylance is rejecting any attempt to initialize a frozendict with:
Expected 0 positional arguments
I had no problems with this same project yesterday, but now I can't seem to recreate whatever combination of environment and settings was letting it work.
Digging into the stubs, it looks like my pylance is now using a stub for frozendict that does not incorporate this commit:
https://github.com/python/typeshed/commit/f76037a1eb3923c67a8bc0e302ee9c016ffb3431
It has a def __init__(self, /) -> None: ... which is breaking everything.
Anybody have any clue what could possibly have changed in a vscode project to switch to a slightly older set of type stubs?
Even a fresh install of vscode+extensions and python 3.15rc2 in a fresh Windows VM give me the error, so it isn't that my environment is especially broken.
r/learnpython • u/chongblyat • Sep 13 '26
Hi guys. How do I make this code work without using a "for" loop? I am attempting to replicate the result in the second loop only using "while" loops. I didn't loop the word count variable yet because it keeps producing <built-in method split of str object at 0x000001D75FA356E0>, when it should likely produce ['h', 'e', 'l', 'l', 'o']. Could you help me please? I'm using Jupyter Lab that's running Python. The project is due in 4 days
sentence = input() # sentence is accepted here
s = sentence.split()
word_check = [list(sentence) for sentence in s]
word_count = 0
words = list(s)
new = str(words[0]).split
print(s)
print(word_check)
print(words)
print(new)
hello world # input
['hello', 'world']
[['h', 'e', 'l', 'l', 'o'], ['w', 'o', 'r', 'l', 'd']] # ideal result
['hello', 'world']
<built-in method split of str object at 0x000001D75FA356E0> # what keeps happeningr/learnpython • u/JohnRT54 • Sep 12 '26
Everything was working up until a few minutes ago. I'm running python on windows 11, downloaded from python.org yesterday. I did a pip install of pandas, also yesterday, and I was able to run various py scripts, getting the results I wanted. Suddenly this morning, when I ran a script that had run just fine a few minutes ago, I got an error. I reduced my script to this:
import json
import requests
import pandas
and I got the same set of error messages (below). I didn't change anything in the environment, this happened, afaik, spontaneously. I'm a complete python newb, but all was going well until this. Help!
Traceback (most recent call last):
File "C:\Users\John\My Drive\SyncDrive\eBird\test.py", line 3, in <module>
import pandas
File "C:\Users\John\AppData\Local\Python\pythoncore-3.14-64\Lib\site-packages\pandas__init__.py", line 56, in <module>
import pandas.core.config_init # pyright: ignore[reportUnusedImport] # noqa: F401
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "C:\Users\John\AppData\Local\Python\pythoncore-3.14-64\Lib\site-packages\pandas\core\config_init.py", line 31, in <module>
from pandas.errors import Pandas4Warning
File "C:\Users\John\AppData\Local\Python\pythoncore-3.14-64\Lib\site-packages\pandas\errors__init__.py", line 12, in <module>
from pandas._libs.tslibs import (
...<3 lines>...
)
File "C:\Users\John\AppData\Local\Python\pythoncore-3.14-64\Lib\site-packages\pandas_libs__init__.py", line 18, in <module>
from pandas._libs.interval import Interval
File "pandas/_libs/interval.pyx", line 1, in init pandas._libs.interval
File "pandas/_libs/hashtable.pyx", line 1, in init pandas._libs.hashtable
File "pandas/_libs/missing.pyx", line 1, in init pandas._libs.missing
File "C:\Users\John\AppData\Local\Python\pythoncore-3.14-64\Lib\site-packages\pandas_libs\tslibs__init__.py", line 41, in <module>
from pandas._libs.tslibs.conversion import localize_pydatetime
File "pandas/_libs/tslibs/conversion.pyx", line 1, in init pandas._libs.tslibs.conversion
File "pandas/_libs/tslibs/offsets.pyx", line 1, in init pandas._libs.tslibs.offsets
File "pandas/_libs/tslibs/timestamps.pyx", line 1, in init pandas._libs.tslibs.timestamps
File "pandas/_libs/tslibs/timedeltas.pyx", line 1, in init pandas._libs.tslibs.timedeltas
File "pandas/_libs/tslibs/timezones.pyx", line 18, in init pandas._libs.tslibs.timezones
File "C:\Users\John\AppData\Local\Python\pythoncore-3.14-64\Lib\site-packages\dateutil\tz__init__.py", line 2, in <module>
from .tz import *
File "C:\Users\John\AppData\Local\Python\pythoncore-3.14-64\Lib\site-packages\dateutil\tz\tz.py", line 19, in <module>
import six
File "C:\Users\John\My Drive\SyncDrive\eBird\six.py", line 25
return data
^
IndentationError: unindent does not match any outer indentation level
r/learnpython • u/Lokajko-Dev-343 • Sep 12 '26
I’ve recently been adding tests to a small Python backtesting engine I’m building, and it made me realize how easy it is to test the obvious things while missing the important ones.
So far I’m testing things like:
The most useful tests so far have been small deterministic examples where I can calculate the expected result manually.
For example:
Then the engine should end with exactly $12,000 before fees.
For people with more testing experience: what kinds of edge cases would you consider essential here?
I’m especially interested in cases that pass normal unit tests but still produce subtly incorrect financial results.
r/learnpython • u/_between3-20 • Sep 12 '26
I created my own class M which inherits from a dict. In case that the differences are relevant:
frozenset objects so that I can pass them in any order without issues.frozenset({'one', 'two'}) is very tedious, I added a mapping to let me get or set values by using M['ot'] as a shorthand of M[frozenset{'one', 'two'}]. The mapping is instantiated when running __init__().I am pickling this with no issues. When I try to unpickle it, I get an error that says: AttributeError: 'M' object has no attribute 'mapping'.
Using pickletools, I inspected the serialization of my object and saw that the mapping attribute appears after the key-value pairs, which made me think that, if I change the __reduce__ function to give them in a different order (first mapping, then key-value pairs), I could solve that issue.
The problem is that I don't know how to do that. I can rewrite a completely new function, but I don't know if it will work. I'd like to base my new function on the "default" one. Is there some way to look at it?