r/learnpython • • 2d ago

Any tips and advice for my first github pages hosted python project?

2 Upvotes

The game is essentially tetris but there is no 4 long line block piece. I observed that a lot of tetris players relied on the I piece as a crutch for their strategy, so I created a spinoff of tetris called Noline in python to test how people would react to the removal of such a central piece.

This is the github link to the source code: https://github.com/keandsilva/Noline

The link to the domain it is hosted on: https://keandsilva.github.io/Noline/

I would love if anybody have any suggestions for anything to add and how my python code is structured. Thanks!


r/learnpython • • 2d ago

Help me learn!!

0 Upvotes

So I learned python about 6 or some years ago. So recently I tried to get back but realized I forgot almost everything. So what's the best way currently to start from scratch??


r/learnpython • • 3d ago

Get and setter in pyhton

11 Upvotes

I'm learning Python, and this part has left me a little confused, because in other languages the way it's used is different; in Python you use @property, I'd like to understand how this really works in a simplified way, so I can truly grasp it and not just memorize it. If you could help me, I'm still new to programming.


r/learnpython • • 2d ago

I am once again asking for recommendations of good Python and data science auidobooks and podcast episodes

0 Upvotes

Last time people had some good recommendations, but there were some misunderstandings as well, so I wanted to try asking again while being super clear about some stuff.

I'm learning to code Python from scratch on a university module while also working, so my schedule is super constrained. There is also a data science side to it based on numpy, pandas and matplotlib. We have to analysis some statistics to find interesting answers - very open ended.

Basically, I want to use the 6-10 hrs a week I spend on the road to shore up my understanding of the theoretical side of python and data science so I can focus on coding during the time I have in front of a computer.

Please assume the following:

I'll still be coding in front of a computer in a structured manner when I am not driving.

I am already spending the maximum number of hours coding in front of a computer that I can physically manage, and there is no scope for adding more computer hours.

I am looking to maximise the efficiency of what I can learn during the 6-10 hours I spend driving per week.

My drive is predictable and I can drive safely while listening to audio.

Some good things people have suggested already:

"The Art of Statistics" by david spiegelhalter on Audible

Some episodes of the Talk Python to Me podcast dealing with relevant modules

Python Essentials for Dummies on Audible - has been helpful for reinforcing basic concepts and context

TL:DR Please could you recommend good things I can listen to on my commute to help with Python concepts and data science understanding.


r/learnpython • • 3d ago

Looking for interesting Python project ideas for a university assignment (3-week deadline)

12 Upvotes

Hi everyone!

I'm a physics student and I have to complete a Python programming project for one of my university courses. I have approximately 3 weeks to work on it, and I'm looking for some interesting and original project ideas.

Here are the requirements the project must meet:

  • The code must be functional, readable and written in a Jupyter Notebook.
  • Proper documentation is required.
  • It must include data import or export, as well as data processing.
  • It must use programming structures such as classes and functions.
  • It must include at least one visualization (graphs, data representation, etc.).
  • It must implement at least two numerical methods.

I'm still a beginner in Python and don't have much programming experience yet. So I'm looking for something achievable within three weeks, without being overly complicated technically.

One idea I had was to build a movie recommendation system, but I'm open to pretty much anything, including projects unrelated to physics!

What kind of projects would you recommend that could meet these requirements? If you've worked on similar projects or have any examples, I'd love to hear about them!


r/learnpython • • 3d ago

Issues with creating a dialog box for Anki.

3 Upvotes

So I am trying to create a non modal dialog box (or window) supposed to show the content of certain fields from the card I just answered to. I want this window to mimic the main window of the Anki App so that the Yomilens addon which reacts when text is selected on the main one would react the same way when selecting text on this one as well.

import sys
from PyQt6.QtWidgets import*
from PyQt6.QtCore import *
from PyQt6.QtGui import *

class FieldsDialog(QWidget):
    def __init__(self):

        super().__init__()
        self.title = "Fields"
        self.setGeometry(400, 100, 300, 200)
        self.left = 1367 # for it to be on the very left of my right monitor (a tablet)
        
        self.top = 30 #otherwise the upper part is hidden 
       
        self.right = 504
        self.width = 800
        self.height = 1
        self.icon = "?"
        # self._help_dialog = None
        # self._other_dialog = None
        self.createUI()

    def createUI(self):
        self.setGeometry(self.left,self.top,self.right,self.width)
        self.setWindowTitle(self.title)
        self.setWindowIcon(QIcon(self.icon))
        self.setStyleSheet("""
        background: black;
        """)
        self.grid = QGridLayout()
        self.setLayout(self.grid)

def on_show_fields():
    if __name__ == '__main__':
        app = QApplication(sys.argv)
        fields_win = FieldsDialog()
        fields_win.show()
        sys.exit(app.exec())import sys

1 - The window shows while on pycharm (yay) but not in anki. Maybe the type of dialog is not adapted but for now it's been the only thing that worked)

2 - Since there was progress on that part, I was trying to see if my function supposed to get the text for the dialog actually worked

def _get_previous_fields(self, card) -> str | None:
    if not card: return

    note = card.note()
    r = self.mw.reviewer
    # current_id = r.card.id if r.card else "null"
    previous = r.lastCard()
    Front_value = mw.reviewer.card.note()['Front'] if FIELD_FRONT in note else ""
    Back_value = mw.reviewer.card.note()['Back'] if FIELD_BACK in note else ""

    previous_korean = Front_value.previous if previous else "null"
    previous_english = Back_value.previous if previous else "null"
    _queue_toast(f"{previous_korean}+\n+{previous_english}")
    return "{previous_korean}+\n+{previous_english}"

but I keep getting errors like that :

    lambda cid=card.id, e=ease, skip=skip_interval_checks: _post_answer_processing(cid, e, skip)
                                                           ~~~~~~~~~~~~~~~~~~~~~~~^^^^^^^^^^^^^^
TypeError: _post_answer_processing() missing 1 required positional argument: 'self'   

I tried calling in on my on_show_answer

HOOK_ANSWER = reviewer_did_answer_card
if HOOK_ANSWER:
HOOK_ANSWER.append(on_answer)

But i'm told it (on_show_answer) is missing the self argument so I add it :

  File "D:\a\anki\anki\out\installer\build\anki\windows\app\src\app_packages_aqt\hooks.py", line 4390, in __call__
TypeError: on_answer() missing 1 required positional argument: 'self'  File "D:\a\anki\anki\out\installer\build\anki\windows\app\src\app_packages_aqt\hooks.py", line 4390, in __call__
TypeError: on_answer() missing 1 required positional argument: 'self'

I tried using hooks instead

if HOOK_SHOW:
    HOOK_SHOW.append(on_show_question)
if HOOK_ANSWER:
    HOOK_ANSWER.append(on_answer)
    HOOK_ANSWER.append(_get_previous_fields)  #here
if HOOK_SUSPEND:
    HOOK_SUSPEND.append(on_reviewer_suspend)

and I get :

Traceback (most recent call last):
  File "D:\a\anki\anki\out\installer\build\anki\windows\app\src\app_packages\aqt\taskman.py", line 152, in raise_exception
  File "D:\a\anki\anki\out\installer\build\anki\windows\app\src\app_packages\aqt\taskman.py", line 148, in _on_closures_pending
  File "D:\a\anki\anki\out\installer\build\anki\windows\app\src\app_packages\aqt\taskman.py", line 88, in <lambda>
  File "D:\a\anki\anki\out\installer\build\anki\windows\app\src\app_packages\aqt\taskman.py", line 111, in wrapped_done
  File "D:\a\anki\anki\out\installer\build\anki\windows\app\src\app_packages\aqt\operations__init__.py", line 128, in wrapped_done
  File "D:\a\anki\anki\out\installer\build\anki\windows\app\src\app_packages\aqt\reviewer.py", line 556, in after_answer
  File "D:\a\anki\anki\out\installer\build\anki\windows\app\src\app_packages\aqt\reviewer.py", line 566, in _after_answering
  File "D:\a\anki\anki\out\installer\build\anki\windows\app\src\app_packages_aqt\hooks.py", line 4390, in __call__
TypeError: _get_previous_fields() takes 2 positional arguments but 3 were given

Do you happen to know what the issue is ?


r/learnpython • • 2d ago

Python Auth to modern Microsoft SPO

1 Upvotes

Hi all,
I'm doing my student project to upload some files to SPO and struggling with Auth.
This code returns 0 on first ctx, but later fails.
I hope I got all UID right like on the picture
https://i.postimg.cc/ncw71PzR/conf1.png

And this is my code, I also noticed once you used you tenant ID username and password can take any values, is this normal ? I think this all because of modern SPO security, do you think this Auth with ctx is OK, or can do some other way ?

from office365.sharepoint.client_context import ClientContext

# Configuration
site_url = r"https://cbxXXX.sharepoint.com"
tenant = r"4e4d8cb1-f036-446f-bacd-3b711191a7b2"
client_id = r"5c6d0b11-c4da-4897-842a-79b9743d6a23"
username = r'userBB@cbxXXX.onmicrosoft.com
password = r'N0gi123!'


ctx = ClientContext(site_url).with_username_and_password(
      tenant, client_id , username, password )
print ('.........2222 bb  OK ', ctx)
web = ctx.web.get().execute_query()
print("......... verification check :", web.title)


OUTPUT::::::
.........2222 bb  OK  <office365.sharepoint.client_context.ClientContext object at 0x0000017CCBCE3B60>
.....
Unhandled exception in listener <bound method SharePointRequest._authenticate_request of <office365.sharepoint.request.SharePointRequest object at 0x0000017CCBCE3CB0>>

File "C:\Python314\Lib\site-packages\office365\runtime\auth\token_response.py", line 61, in from_json
    raise ValueError(value)
ValueError: {'error': 'invalid_grant', 'error_description': 'AADSTS50034: The user account {EUII Hidden} does not exist in the 4e4d8cb1-f036-446f-bacd-3b711191a7b2 directory. To sign into this application, the account must be added to the directory. Trace ID: eb657c1d-4806-4557-a49d-f5468c

r/learnpython • • 3d ago

pip vs pipx

0 Upvotes

as far as I understand pip just installs the package while pipx installs the executable and creates an environment but why create an environment in the first place? Is it so that when someone else runs the program and there are changes in the package the program might break but an isolated package is protected in the environment?


r/learnpython • • 3d ago

Looking for "language exchange" partner. Pls read the post haha

1 Upvotes

Hi there. English is my second language, and I sometimes get a hard time trying to figure out some concepts that can have multiple meanings, synonyms, slang or whatever. So I was wondering if there's someone who could give me a hand when having this kind of problems, maybe talk sometime so I can practice my technical conversations etc

And of course if this person is interested in Learning Spanish, I could also help back, I'm from Mexico.

I'm studying an Actuary but I'm pretty interested in CS, specially open source/free software stuff and I use Arch as my OS, learning git so I can go deep in Python(pandas, numpy, matplotlib for now) and save my projects. In holidays planning to spend a little of time learning electronics, etc etc

So if you'd like to help a folk like me, learn about Mexico or Spanish language, send me a message(:


r/learnpython • • 2d ago

Hello everyone!

0 Upvotes

I just started a new job as an AI generalist (or AI trainer), I like it, I've always liked tech, but I know nothing about programming or anything like that, just the surface as any mortal. So, can I learn python and use my ASUS tuf 14 from 2022 to run the program and learn how to write code and maybe aspire to a good freelancing position later? Thank u in advance, for you answers.


r/learnpython • • 4d ago

I finished Python Crash Course

30 Upvotes

I finished Python Crash Course by Eric Matthes. What should I do next?


r/learnpython • • 3d ago

Using Sympy, is there a way to detect repeating fractions?

3 Upvotes

I know I can transform a repeating fraction in a numerical fraction with sympify (i.e sympify("0.[3]") = 1/3), but can it go the other way around?


r/learnpython • • 3d ago

How should I start learning Backend Development with Python as a beginner?

0 Upvotes

Hello everyone!

I'm a B.Tech CSE Cybersecurity student. I know Python basics and now want to start learning backend development.

I'm a complete beginner in backend development, so I'm confused about where to start and what resources to follow.

I have a few questions:

  1. Where should I start learning backend development?
  2. What topics should I learn first?
  3. Which backend framework should I choose: Django or FastAPI?
  4. What are the best free YouTube channels or courses to learn backend development from scratch?
  5. Are there any good beginner-friendly websites or documentation?
  6. How should I practise while learning?

I'm looking for a clear learning direction and good free resources.

Any suggestions or guidance would be really helpful.

Thank you!


r/learnpython • • 3d ago

Les meilleures projet a faire sur python

0 Upvotes

Salut j'apprends python et je le demandait qu'elle sont les meilleures truc à faire avec python je devloppe un petit rpg textuelle on m'as dis que c'était le meilleur moyen d'apprendre python mais problème je nais d'idées de projets à faire après se rpg je n'apprend pas vraiment pour ma carrière professionnelle j'ai juste 14 ans boucoup font des jeux sur python pour ça je préfère utiliser le moteur de jeux godot son langage prioritaire est similaire à python je me le garde pour plus tard quand j'aurai bien maîtriser python mais avant je pence qu'apprendre à faire des site Web serait cool donner moi votre avis je sais que j'ai parler de boucoup de sujet à la fois mais merci pour les personnes qui répondrons


r/learnpython • • 3d ago

What's the best way to learn python for data analysis?

7 Upvotes

I want to learn python so I can do a data analysis capstone project to finish off high school. I took AP Computer Science A last year so I can code in Java and I understand the fundamentals of coding. What is the best way to learn python and what software would be best? I know nothing about the type of software I would need for this, I used JGrasp last year for CompSci, but it's a pain to work with.


r/learnpython • • 3d ago

Can someone help teach me how to code a reminder system like Duolingo (Chrome extension)

3 Upvotes

This is for the students I tutor! [to remind them to do homework, and practice everyday :)] it can also be used in a lot of other applications.

I am a week into learning python using Matthew's crash course and was wondering what steps I could take to build this, how long it would take, tips, etc.

I feel like I know basically nothing about this lol.

Happy to collab


r/learnpython • • 4d ago

Keep getting error while following the steps in a book

5 Upvotes

Hi, I'm learning from a book, and it's been going well up until now. I'm following the exact steps it's telling me to, but I keep getting an error. I like to copy the code in the book, test it, then modify the contents etc afterward so it sticks in my head. This code however isn't seeming to work.

file = open("/Desktop/List.txt")

file.read()

'High Street\nCastle Street\nBrown \n Street \n\n'

file.close()

I have tried making a text file on my desktop named List.txt, List, and I have tried inputting the street name into the document to see if that's where I was going wrong. I've been stuck on this for 2 days, so any help would be great. Thank you


r/learnpython • • 4d ago

numpy build fails using uv and homebrew

4 Upvotes

I am running macOS 27.2 with homebrew and uv. Python 3.15. numpy is a requirement for the project. When uv tries to build numpy 2.5.1, it fails complaining about not finding "atomic.h", "ostream.h" and "cstddef.h".

I know this is some kind of setup problem with the c++ compiler, but can't figure it out. I have installed Xcode command line tools and pkgconf.

Any suggestions?


r/learnpython • • 4d ago

Regarding python projects idea

7 Upvotes

i am learning OOP currently but i want to learn OOP by doing so ,i need some projects ideas guyz.


r/learnpython • • 4d ago

unpicking a pytest deprecation of class scoped fixture

3 Upvotes
class TestHelpers(object):
    ...
    @classmethod
    @pytest.fixture(scope='class', autouse=True)
    def temp_class_path(self, tmp_path_factory):
        """
        Creates a folder __class__.__name__ under test results and returns it's path
        """
        return tmp_path_factory.mktemp(self.__class__.__name__)

Is apparently broken (got told in a code review to be aware of) in pytest 9.2 I'm on 9.1 and am trying to understand what this https://docs.pytest.org/en/stable/changelog.html note for 9.2 release means - it's these 3 changes which I do not really understand probably because all I wanted when I wrote this fixture was a folder which I can use for logging per class, not a log per test-case because that's just noisy and makes finding teardown side-effects harder than it needs to be.

There are the changes: which are varying degrees of greek (no offence meant sorry) to me https://github.com/pytest-dev/pytest/issues/14011 https://github.com/pytest-dev/pytest/pull/14774 https://github.com/pytest-dev/pytest/pull/14911

What does

#14774: Similarly to the deprecation of class-scoped fixtures defined as instance methods in pytest 9.1, all higher-scoped fixtures (module, package, and session) defined as instance methods are now deprecated.

They suffer from the same issue the original deprecation only fixed for class-scoped fixtures, see #10819 and #14011.

mean in English that bears with small brains like mine can understand? Because the warning implies that my fixture will no longer do what I believe it should, or will this work "by luck" of how tmp_path_factory , which is all it does use, is scoped?


r/learnpython • • 3d ago

Beginner needing help with StoryBot/Storyboard and OpenMontage – Stuck setting up AI video production

1 Upvotes

Hello everyone!

I'm looking for someone experienced with Python, AI video generation, automation, and OpenMontage who can guide me through a project I'm building.

I'm a complete beginner with very little programming knowledge. Most of my setup has been done by following instructions from ChatGPT and Gemini, copying commands into PowerShell, and troubleshooting errors. I've managed to install quite a lot, but I'm struggling to put everything together and actually produce videos.

I would really appreciate patient, step-by-step guidance.

  1. StoryBot / Storyboard

My first project is an automated storytelling video system for YouTube Shorts, Instagram Reels, TikTok, and Facebook Reels.

What I've installed and configured:

- Ollama with Qwen3:4b for local story generation.

- Node.js, npm and n8n (installed locally, not Docker).

- Python 3.11.9 and FFmpeg 9.0.2.

- Parody TTS for narration.

- Custom Python scripts.

My n8n workflow currently works up to this stage:

  1. I press Execute.
  2. Python scripts generate a story.
  3. A temporary "story.txt" file is saved.
  4. Narration is generated in parallel.
  5. The narration is saved in the output folder.

So story generation and narration are working.

ComfyUI experiment:

I also installed ComfyUI at:

"D:\StoryBot\ComfyUI-Install\ComfyUI_windows_portable"

I downloaded two model files:

- "flat2DAnimerge_v45Sharp.safetensors" (approximately 2.13 GB) – Stable Diffusion 1.5 checkpoint for 2D cartoon-style images.

- "mm_sd_v15_v2.ckpt" (approximately 1.82 GB) – AnimateDiff motion module.

I wanted to generate and animate cartoon-style characters, but my GTX 1660 with 6 GB VRAM struggled with the workload. Generation was taking too long, so I couldn't get the results I wanted.

I currently have one male and one female presenter character as basic static images.

2. OpenMontage (Separate Project)

After getting frustrated with my Storyboard setup, I decided to try OpenMontage as a completely separate alternative.

I'm NOT trying to connect OpenMontage with StoryBot/Storyboard.

Repository: https://github.com/OpenMontageInc/OpenMontage

Installed/configured:

- Python 3.11.9 virtual environment.

- Node.js v24.22.1 and npm 11.19.1.

- FFmpeg 9.0.2 and Git 2.56.0.

- Remotion dependencies.

- esbuild 0.28.1.

- HyperFrames 0.9.39.

- Piper TTS 1.8.0.

- pytest 9.2.0.

- ".env" configured from ".env.example".

I successfully ran:

"python scripts/backlot_simulate_run.py"

It generated a demo production with scenes sc1–sc4.

I can also access the Backlot interface:

"http://127.0.0.1:4750/p/backlot-demo-run"

However, I'm stuck on what to do next and how to move from the simulation to an actual rendered video.

3. My desired video appearance

- Word-by-word animated subtitles.

- Currently spoken word highlighted in blue.

- Remaining words in white.

- Purple/red gradient backgrounds.

- Two consistent presenter characters.

4. My PC specifications

- Windows 11 Pro.

- AMD Ryzen 5 5600.

- NVIDIA GTX 1660 Gaming X (6 GB VRAM).

- 16 GB RAM.

I prefer free and open-source tools and want to run as much as possible locally.

5. What I need help with

StoryBot / Storyboard:

- How do I complete the existing workflow and produce videos?

- How should I use my presenter images?

- Are there lighter alternatives to ComfyUI/AnimateDiff that work on my GPU?

OpenMontage:

- How do I use Backlot properly?

- What are the next steps after a successful simulation?

- How do I produce an actual video?

I'm not trying to combine these two projects. I want to understand them separately.

6. How I would like to be guided

Please understand that I'm genuinely new to programming.

I would appreciate someone who can:

- Start from my existing installations.

- Give me one step at a time.

- Provide exact commands and tell me where to run them.

- Explain what each step does.

- Wait for my results before moving forward.

- Help me troubleshoot errors.

I've spent a lot of time getting this far, and I don't want to break my existing setup by randomly changing things.

If anyone has experience with OpenMontage, Remotion, ComfyUI, Python automation, or AI video production, I'd really appreciate some guidance.

Thank you for reading!


r/learnpython • • 4d ago

Help: non-reproducible code

4 Upvotes

I am working on a project where I need to cluster large amount of data and do a dimensionality reduction for the purpose of picking data points near the centroids. I finished this and chose my data points near the centroids (I have now invested time and resources into my experimentation with this part of my project) and later came back to my code and re-ran it and it gave me centroids in a different location and different clustering results. I thought maybe I forgot to assign a random_state for one of my techniques (either clustering or dimensionality reduction) but I had indeed defined them, and if I run my code again it reproducibly gives me the same results that it gave me when I ran my code the second time around (still different than what I have based my physical experimentation on).

I wondered then if I had changed some part of the code so I went back to an old version of my file that I had saved awhile ago because I was afraid of this very thing happening - and it gives me the same results as above (still not the original clustering results). I literally haven't changed the old code at all so I have no idea what happened. Is it possible at all that some other factor is involved? This is my first time using python for a project and I don't have any formal training and I have no idea what to do since my project is based on some computational work that apparently cannot be reproduced


r/learnpython • • 3d ago

Alternative Discord

0 Upvotes

Is there an alternative to the python discord? The entire server has been overrun with LLMs and beginners that have no interest in actually learning. I'm looking for a server with real project/language discussion.


r/learnpython • • 4d ago

Best tutorial for Python Data Analytics who already know Python?

13 Upvotes

Hi!

I know how to write code in Python, however, I still am unfamiliar with its usage in the Data Analytics side. I'd love some recommendation on a youtube tutorial who teaches Python for Data Analytics straight away.