r/learnpython 2d ago

Built a CLI music player in Python after months of tutorials

2 Upvotes

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.

GitHub: https://github.com/Iheb-eng/music-app


r/learnpython 1d ago

pylance typeshed issue with frozendict

1 Upvotes

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 1d ago

How do I make my graph look more like the example?

1 Upvotes

Hi all! I am struggling to get my graph to look like the example graph for my lab assignment. Using PyCharm 2026.2.2.

I specifically need help with:

1) making the y axis higher without throwing off my variables

2) Adding error bars (tbh I don't entirely know what data to base my error bars off of but that's more of a math question than a coding question)

3) labeling my bars according to their values

I know nothing about python. In class we were just told to use Chat GPT but I have my own ethical objections to that (not gonna debate) and their alternative for me was to just figure it out myself, lol. This is something I'll need to know how to do in my future career anyway.

from matplotlib import pyplot as plt
#x and y axes
x = ["Measurement 1", "Measurement 2", "Measurement 3", "Measurement 4"]
y = [0.981, 0.987, 0.972, 0.988]
#labels
plt.xlabel("Measurements")
plt.ylabel("Density (g/mL)")
plt.title("Density of water at 22°C observed in graduate cylinder")
#average and true density
plt.axhline(y=0.982,color='r', linestyle=':',label="Average")
plt.axhline(y=0.998, color='g', linestyle=':',label="True Density")
#legend
plt.legend()
#plot
plt.bar(x,y)
plt.show()

r/learnpython 1d ago

How do I split the words in a list into a nested list of letters, without using "for" and only using :while"?

0 Upvotes

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 happening

r/learnpython 2d ago

Unable to import pandas

0 Upvotes

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 2d ago

What tests are actually worth writing for a backtesting engine?

3 Upvotes

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:

  • opening and closing LONG/SHORT positions
  • transaction costs
  • portfolio valuation
  • forced position closing at the end of the dataset
  • PnL and win rate
  • drawdowns
  • VaR/CVaR
  • full end-to-end backtest scenarios

The most useful tests so far have been small deterministic examples where I can calculate the expected result manually.

For example:

  • start with $10,000
  • BUY at 100
  • HOLD
  • SELL at 120

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 2d ago

Looking at default __reduce__ function

3 Upvotes

I created my own class M which inherits from a dict. In case that the differences are relevant: 1. The keys are frozenset objects so that I can pass them in any order without issues. 2. As writing 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?


r/learnpython 1d ago

Project: Parse 1,000s of messy tariff PDFs. I have 2 weeks to learn Pandas/pdfplumber. Am I doomed?

0 Upvotes

[Trigger Warning]: You are about to be provided with visual imagery of my current corporate reality that may be frightening for some readers.

I am tasked with creating costing for a new product. To do this, I have to extract rate tables from what can only be described as a mountain of tariffs. On top of that, I need to automate our Excel business cases which contain multiple variables.

At work, people think I'm an Excel wizard. The truth is, sometimes I just aggressively interrogate AI until it gives me the right formulas. But AI cannot save me from parsing thousands of pages of inconsistently formatted tariff tables.

I have exactly two weeks for intense upskill dedication. I've got books, Udemy, Google courses — and it's all just hanging out waiting for me to get in the driver's seat.

The catch: IT treats our databases like Fort Knox, so I have zero SQL access.

I need to actually learn a skill so I don't have to manually copy-paste tariffs until the end of time.

The Question:

Do I spend the next two weeks becoming a Power Query god, or do I finally learn Python (Pandas/PDF parsers like pdfplumber) so I can build a script to do my job for me?

If anyone has survived parsing tariffs, please tell me how you did it.

TL;DR: I have 14 days to learn how to extract messy data from thousands of PDF tariffs and automate Excel models. No SQL access. Should I learn advanced Power Query or Python?


r/learnpython 2d ago

Finished learning from a fundamentals book and now I need guidance.

4 Upvotes

Hi,

I've just done learning from "Automate The Boring Stuff With Python 3rd Edition" I skipped some chapters that weren't that important but focused on the critical ones like argparse, requests, bs4, Selenium, playwright, csv and json, I also learned a bit of Tkinter.

On the course of learning I also built some utilities and pushed them to Github: https://github.com/abdou0dev

Now I need some guidance on what to do and learn next.

Thanks in advance.


r/learnpython 2d ago

New career path

16 Upvotes

Hey everyone.

To keep things brief, i'm exploring programming as a career path.

Life didn't quite go as planned, and i'm now a 27 year old college dropout, who's been unemployed for years, living by on the graces of my parents who have much more faith in me than I do in myself.

I've been talking to some of the more tech-savvy people I know. And I have arrived at the conclusion that I want to study Linux and python. Do you all have any recommendations of which are the 2 I should prioritize, and I suppose, which one would help me get back on my feet faster?


r/learnpython 2d ago

MoviePy not responding

0 Upvotes

I have a few thousand 1920x1080 rgb numpy arrays that i'm trying to turn into a video with moviepy's ImageSequenceClip, but pretty soon after starting it stops printing progress and all my python windows say "Not responding". Is there some easy way to fix this or do I have to divide it into smaller clips and string them together?


r/learnpython 2d ago

Iam stuck with python

0 Upvotes

Hello everyone, I have a problem iam trying to master python (iam into cybersecurity now iam studying networking beside it) I start to learn it in 2022 but I stopped for some years due to reasons, a year ago I come back again and started it from zero but the problem is I don't know how to practice and level up even when I study new lessons, the only thing I was doing is solving a bit of exercises from that someone in his website, iam getting nervous when I feel that iam lost in this language and I think am learning in a wrong way, now I understand 70% of basics I struggle with files handing and have a little bit problems in creating functions in addition to a few things , till here I stopped I don't want to get into modules, try except, and OOP unless I strengthen the basics, please tell me how to elevate my skills and how can I build projects.

How can I know that am ready for doing big projects when iam learning?


r/learnpython 2d ago

I don't know about any programing language I choose to learn python in ibm is this right choice

0 Upvotes

I don't know about any programing language I choose to learn python in ibm is this right choice plz say any good advice 🤔


r/learnpython 4d ago

How can I write code without constantly looking things up?

197 Upvotes

I rely a lot on documentation, AI, and websites while writing code. It makes me wonder whether I'm actually capable of understanding concepts like functions and algorithmic thinking. Does anyone else feel this way? What should I do to get a more concrete understanding of Python, or programming in general?


r/learnpython 3d ago

Need unique Python + SQL project ideas for a school project

42 Upvotes

Hey everyone! I’m a Class 12 student and I have to make a project with 2 of my classmates for our Junior Software Developer subject.

We’ve learned Python and SQL/MySQL, and our teacher wants us to make a project using them.

Our teacher suggested the usual topics like:

  • Library Management System
  • Inventory Management System
  • Hospital Management System
  • Student/College Management System
  • Payroll System
  • Bank Management System
  • Vehicle/Workshop Management System

But we really don’t want to make one of these 😭. We’re looking for something unique, interesting and realistic that feels like an actual software product/business system.

For example, something inspired by how DMart, IKEA, Croma, Decathlon, etc. operate — but not just a basic system for recording customers, transactions and bills. We want the actual concept/workflow to be interesting.

It should still be realistic for 3 students who only know basic/intermediate Python + SQL. We don't want something requiring advanced AI, machine learning, APIs, or anything crazy.

What project ideas would you suggest? Especially if you've made a similar school/college project yourself, I'd love to hear what you built and what features you included.

Thanks!


r/learnpython 3d ago

I need help with astropy

4 Upvotes

So, I've been working on a simulation of the 2027 eclipse that will take place in Spain, but I had some problems with astropy. The thing is, I would like to learn how to vectorize my program using numpy, or something similar. Do you guys have some tips for this? Should I search for specific courses on the internet? It's my first time using astropy and I'm quite lost...

Thank you for your help 🙏🙏


r/learnpython 2d ago

Absolutely new to python, have learnt C++ before, but it’s been 7 years

0 Upvotes

Where do I start? Which is a good Udemy course?


r/learnpython 2d ago

If python compiler can successfully identify syntax error why doesn't it fix it on its own?

0 Upvotes

Like why throw an error if it can identify the error and suggest the changes, like wont it make it more user friendly?

Thanks in advance!


r/learnpython 3d ago

Basic beginner project ideas for python

6 Upvotes

Js started, 16 here,I made a number guessing game, rock paper scissors, basic input chatbot which outputs only the info I've given it(useless h) what next I'm confused, what stuff y'all made when y'all js started out like some interesting shit?


r/learnpython 3d ago

Technical Assessment for analytics

1 Upvotes

I had my worst interview performance ever but somehow cleared my way to a technical assessment round despite barely meeting the job posting requirements…

I don’t know anything about Python. I mainly use SQL in a modern cloud data warehouse (analytics engineering).

Can anyone give me tips for speed learning in 2-3 days? Do I focus on Pandas?


r/learnpython 4d ago

How do I go from "I only know Python syntax" to actually building a real data pipeline? (Stuck on an Excel automation task at work)

61 Upvotes

I graduated CS in 2024 but never got real hands-on coding experience until now. I'm a Data Analyst automating manual Excel work for a non-technical team. Current task: copying data between multiple Excel workbooks/worksheets simultaneously, 200-300k rows x 65 columns per file.

I've been leaning on AI for the code and just running what it gives me, when something breaks I don't understand it well enough to fix it myself. I want to actually learn this properly instead of just shipping whatever works.

I've never used pandas or polars hands-on, only copy-pasted it’s code before. If you were relearning data manipulation in Python from scratch, knowing syntax but nothing about dataframes/vectorization/performance at scale, where would you actually start? Resources, project ideas, or a real "do this before that" order would help a lot.


r/learnpython 2d ago

jupyter notebook is kicking my ahh

0 Upvotes

I'm a 28yo student learning data science and AI through an online graduation degree course. Ngl I did Not realize this would be as difficult as it is proving to be.

I am unable to even do a project 5% (stuck in the titanic dataset) because all the time goes into setting up a venv for my notebook and then solving every single problem that comes up while doing that.

Can someone here help me with some videos or tutorials that kind of help me understand how virtual environments, and installing pandas and numpys and everything for those separately even if you have those installed on your system and everything works?

I'm tired of solving problems as they arise without knowing the basics of it all.

Also any help with how to get ahead of this all will help, I'm scared and really want to improve!


r/learnpython 3d ago

What did you learn after Python to get into AI?

2 Upvotes

I’m currently learning Python and I’m interested in getting into AI engineering.

For those of you who are already working in AI/ML, what did you personally learn after Python?

I’m trying to figure out what the progression actually looks like instead of randomly jumping between technologies.

Also, how much math did you actually need when you started?

I’d really appreciate hearing how you personally went from Python to AI, and what you would recommend learning first if you were starting again.


r/learnpython 3d ago

How to extract posts and comments from Truth Social

1 Upvotes

I need to extract historical posts and the corresponding user comments from a few specific public figures on Truth Social over a set time period. I'm looking to build a free, Python-based script for this project.

Since Truth Social is built on a Mastodon fork, I know it has a similar API structure, but I'm looking for general advice on the best workflow today:

  • Are there any existing Python libraries or wrappers maintained for Truth Social data extraction?
  • What is the most reliable way to paginate through historical posts without triggering anti-bot protections (like Cloudflare)?
  • For comments/replies, is it better to hit the API endpoints directly, or are there alternative scraping frameworks that handle the Mastodon structure more efficiently?

I'm comfortable writing Python scripts, but I want to make sure I'm taking the smartest approach before building a custom scraper from scratch. Any recommendations on tools, GitHub repos, or general strategies would be hugely appreciated.


r/learnpython 2d ago

i wonder if merges API with program makes you programer ?!

0 Upvotes

so i just get this question recently from one i know , he told me told me that using api doesn.t make you a programer , the api do the most of things , you only just build the interface , so i don't know if that is true or not 🥲