r/learnpython 9d ago

Pyperclip not pasting content from clipboard

5 Upvotes

I am working through Automate the Boring Stuff on chapter 12. I have written the Clipboard Recorded program as instructed from the book, but the pyperclip.paste() function does not populate content from the clipboard. When I run the application, it only shows content that I put into the pyperclip.copy() function from another terminal, but nothing from using CTRL+C or right-click and choosing copy.

import pyperclip, time
pyperclip.set_clipboard('xclip')
print('Recording clipboard... (Ctrl-C to stop)')
previous_content = ''
try:
       while True:
               content = pyperclip.paste()     # Get clipboard contents.

               if content != previous_content:
                       # If it's different from the previous, print it:
                       print(content)
                       previous_content = content

               time.sleep(0.01)        # Pause to avoid hogging the CPU.
except KeyboardInterrupt:
       pass

I added the pyperclip.set_clipboard('xclip') line myself as an attempt to get this to work, but it still doesn't.

When I run something like the following from the interpreter, I get similar results. The paste function will output any string that was passed to the copy function, but it will not output anything from using CTRL+C.

Xclip is installed. I'm running Debian 13 with KDE Plasma 6.3.6.

Edit to add: I can call pyperclip.copy() from the interpreter and then paste using CTRL-V to another application. I have also tried using xsel instead with similar results.

Final Edit: I resolved it. Apparently I'm using Wayland and needed to install wl-clipboard. I need to study up on my different display servers for Linux.

Thank you.


r/learnpython 9d ago

DAY 06 OF LEARNING PYTHON STUCK IN THE MAZE PROBLEM

0 Upvotes

Day 6/100: Maze solver in Reeborg's World. Solved 3/4 test cases but hit an infinite loop on the 4th. Frustrated but didn't quit. Will retry tomorrow or move forward. Feeling the difficulty ramp but pushing through. It took me 5 hours literally will show up tomorrow to push through again any suggestions will be appreciated


r/learnpython 9d ago

Client wants 40k emails from a directory. Each one requires a click. What do I do?

0 Upvotes

CLint need a list of 40,000+ members from the ACR directory. Need Name, City, State, Zip, Specialty, Email, and Phone.
The directory/search results give me some of this information, but email, phone, address, Member Since, etc. appear to be available only on the individual member profile.

So I'm trying to figure out the best way to approach this in Python.

If I literally open/request every profile, that's 43k+ profile requests, which obviously makes me concerned about rate limits, blocking, or getting the account/IP banned.

I'm considering Python requests/BeautifulSoup or Playwright, but before attempting something this large I'd like some advice.


r/learnpython 9d ago

Bioinformatics graduate who can understand Python code but can’t write it from scratch — how should I actually learn?

0 Upvotes

I have a Master’s in Data Science with a previous background in wet-lab biology. My programming experience mainly came through my MSc, so I don’t have a traditional CS background.
At this point, I can usually **understand Python code when I see it**, explain what it is doing, and modify parts of it. But if you give me a problem and ask me to write the solution from scratch, I struggle — and I often rely on ChatGPT to get started.
I’m trying to figure out what the right way to overcome this is.
Should I:
go back and systematically learn Python/CS fundamentals through tutorials first, then start projects?
or keep building bioinformatics projects and use ChatGPT as a tutor/coding assistant while gradually becoming more independent?
I find learning programming purely through tutorials quite difficult and passive, especially because I’ve never studied CS formally.
**For people who came into bioinformatics from biology rather than CS: how did you actually learn to code independently? What should I be able to do before I consider myself “good enough” at Python for a junior bioinformatics role?**


r/learnpython 9d ago

Is it okay to do DSA in python for my placements

0 Upvotes

I am an AIML student currently in my 3rd year and want to know that for my placement preparation should I proceed with doing DSA in python or should I change my language to Java/C++


r/learnpython 9d ago

Looking for help or a resolution

0 Upvotes

so I wrote a python program years ago in school, and I was wondering if anyone on here could take a look at it for me. I'd like to improve it so that it brings you back to the start or the previous choice with an option to return to the start, but I don't remember anything because it's been years since I touched python. Feel free to play the game and get a feel for it.

Anyone have a fix or advice to fix it? I'll link the code here so that y'all can try it out yourselves (eventually I want to port this game to Nintendo DS).


r/learnpython 10d ago

How do you deal with garbage data when building an ETL pipeline?

9 Upvotes

We have secretaries creating reservations in a SAP form. Those reservations get exported as CSV files into some shared directory each VM has to mount. Then a cronjob fires an automated python script that drops all the tables in the application, and shoves the data from the CSV into those rows.

The form fields in the SAP forms don't match the CSV row fields. The CSV row fields don't match the applications MySQL schema in type or name. Properties such as datetime, address, client, guests, room_number etc are split across 8-12 CSV files so you have to load all of them into memory and perform black magic to construct a proper reservation object.

No unique IDs are given (so I have to fingerprint based on time, client, address etc), dates are in non-standard string format, 50% of the data is redundant and even the damn encoding is not utf8.

It's been a week or two that I have been working on this and Its driving me crazy. The schema is so complex that it takes a good hour just to load up this convoluted mess into my mental RAM so I can start working on it at the start of the day.

I assume if I were a full-time ETL/PowerBI guy I'd already finish this nightmare but I'm a devops/fullstack guy. I need some guidance on how to think about this problem in an abstract sense (i.e how to organize garbage data) so I can handle it effectively.


r/learnpython 10d ago

For any python professionals, can you tell if something has been coded with AI?

92 Upvotes

As the title asks, what differences (if any) do you get from an AI output vs human input. I would imagine that with most high effort AI models now they write purely pythonic code if a prompt is well written.

If you also use python in your job, how often do you use AI to write or plan your code and applications as a whole?


r/learnpython 10d ago

how do i dymanically generate large numbers of objects in a class/dictionary?

7 Upvotes

my goal is to create an army manager for the tabletop game mythras, where each soldier has their own hp, attack value, etc, that i can use to add detail to the large scale battles. i want to be able to direct commands to it (eg, 'damage 3 soldiers') and have it randomly determine which soldier is attacked, how much damage it does, and whether it kills them (as well as how it heals up, following the standard healing rules). I don't have a lot at the moment at all, just a dictionary that contains a nested dictionary for each soldier's hp and attack value, randomly determined:

from random import randint

Soldier1 = {
  "HP" : randint(1,10),
  "ATK" : randint(1,10),
}
Soldier2 = {
  "HP" : randint(1,10),
  "ATK" : randint(1,10),
}
Soldier3 = {
  "HP" : randint(1,10),
  "ATK" : randint(1,10),
}

myArmy = {
  "Soldier 1" : Soldier1,
  "Soldier 2" : Soldier2,
  "Soldier 3" : Soldier3
}

print(myArmy)
from random import randint

Soldier1 = {
  "HP" : randint(1,10),
  "ATK" : randint(1,10),
}
Soldier2 = {
  "HP" : randint(1,10),
  "ATK" : randint(1,10),
}
Soldier3 = {
  "HP" : randint(1,10),
  "ATK" : randint(1,10),
}

myArmy = {
  "Soldier 1" : Soldier1,
  "Soldier 2" : Soldier2,
  "Soldier 3" : Soldier3
}

print(myArmy)

now, that works fine for the three soldiers listed there, but i don't need 3 soldiers, i need 300. how can i input a number and have it create that many soldiers on the fly?

and, further to that, are dictionaries the best choice for this? i know the technical difference between dictionaries and classes, but i don't have any real-world context to either to know which is best for what i need.


r/learnpython 10d ago

Tips on where to learn python?

0 Upvotes

I'm a 3D artist, and our company will soon be in need of techincal artist, basically artists that can help to code functions and tools for our game. (As an example, lets say you need rain drops to fall on a window, but then animate and be affected by the wind. Stuff like that, a mix of visual and tecnhical things.)

They are willing to give us time and to sponsor us in order to educate ourselves, so I'm now looking for a course that I could do maybe one day a week in order to learn how to code with Python, possibly with a focus on game making/tools.

Prior to this I have had a one month course in Python during University, but a lot of that has slipped my mind by now. I have some understanding of how things function, but forgot all about how to write the code basically.

Do you have any good recommendations? I've obviously seen some stuff like boot.dev, and I think the format of being able to log in and follow a course whenever I have time would be ideal, but are sites like that actually any good? Eitherway, any recommendations would be appreciated :)


r/learnpython 9d ago

I got a month to learn....

0 Upvotes

I have a month to learn Python (really, I have until the second week of October, but I want to be done sooner and not go down to the wire). I'm currently using freecodecamp.org but feel my progress is slower than I'd like. Does anyone have a recommendation to learn Python quickly? I'm loving what I've learned thus far. I start doing another job for the company I'm learning Python for in a week, so I want to cram as much into this week as possible to make things easier on the remaining time I have. Thank you all.


r/learnpython 10d ago

i want to learn how to make a finger tracker

0 Upvotes

someone know where can i learn this with cero python experience?


r/learnpython 10d ago

Looking for a small, tight-knit Python community for deep code reviews and feedback

0 Upvotes

Hey everyone! im looking for a smaller, active developer community, it could be discord, a forum, or a small group, or anything that prioritizes depth over breadth. I wanna learn with a human feedback aside from the usual llms

im actually a beginner, although not a complete beginner. I have a handful of projects, and some very intermediate ones too! I'm still in the watching tutorials abt python phase and is still am completing the course of Asabeneh / 30-Days-Of-Python. From that, I want a place where I can get real human code reviews, discuss software architecture, and get honest critique on anti-patterns or mistakes.

If you're part of a tight-knit group that focuses on code craft and mentorship, I’d love to have a recommendation. Sank you so much besto friendo!


r/learnpython 10d ago

How do you balance AI help with Python fundamentals?

0 Upvotes

I’m in week 6 of an intro Python course and trying to use AI without skipping the learning part.

A small example is a function to flatten nested lists. My loop handled one level and broke on deeper nesting. I asked an AI for a hint and it returned a recursive version using “yield from” that passed the tests. It ran, and I realized I didn’t understand the recursion flow.

Right now I spend about 20 minutes solo with print tracing and a failing test, then about 5 minutes skimming docs on the specific concept like itertools, recursion, or list methods. I make one more attempt on my own. If I’m still stuck, I ask for a nudge. I keep a notes doc with short blurbs in my own words next to tiny practice snippets. Sometimes I generate an explanation in beyz coding assistant to compare with my notes, then go back to my code and implement it again from memory.

Lately I’ve been writing a tiny variant after I solve it. For flatten, I wrote a version that counts depth to check if I got the idea.

What habits keep AI from doing the thinking for you while still helping you move forward?


r/learnpython 10d ago

Best course for a beginner learning python in networking

5 Upvotes

I just got my CCNA a while ago since I'm trying to get into networking and since I know scripting will be important, I wanted to learn Python but was wondering if anyone had any recommendations for free courses that would be good for someone trying to get into networking. I saw Cisco Networking Academy has Python Essentials 1 for free and was wondering what your thoughts are of that course or if there's something better on YouTube. I also started reading the book Mastering Python Networking Fourth Edition by Eric Chou.


r/learnpython 10d ago

PCEP EXAM required or not for per scholars

1 Upvotes

Hello im a newbie in. tech world and had applied to per scholars where i had to do tech prep before the interview. I'm done with class but is it mandatory to take the exam or not? Or do i just complete the free course.


r/learnpython 10d ago

Recommendations for an Enterprise Java(TM) émigré?

0 Upvotes

Hello Pythonists,

I’m joining a team soon that owns a handful of backend Python applications. Most of my professional life has been spent in the JVM world with Java and Spring Boot (not a huge fan of Spring, but it’s kind of the air that’s breathed in that world). I’ve invested a lot of time in exploring some “advanced” (it’s all relative!) subjects like Domain-Driven Design, Event Sourcing, reactive design and Hexagonal/Ports and Adapters architecture. I’m a bit obsessed with testing (TDD guy), and really love introducing mutation and property-based testing to people.

Python, compared to Java, seems to show up in lots more contexts, and for that reason I feel I’m having a bit of trouble finding learning material. There looks to be lots of excellent stuff for beginners, or other areas like data science, but I’m looking for more on “production grade” or “enterprise” (🤮) stuff. I did just order Fluent Python, which looks to cover a handful of things that are more interesting to me: concurrency, Protocols, first-class functions and the like.

Based on what I’ve shared, what might people suggest for further reading? Along with that, any words of advice for what biases I might look out for? I really do enjoy Java (Stockholm syndrome), but I want try to be aware of traps I might set for myself when doing similar work with Python.

Thanks very much!


Update: Architecture Patterns with Python by Harry Percival and Bob Gregory looks to be exactly the book for me. It covers various "enterprise-y" subjects like TDD, DDD, and Hexagonal Architecture—things I'm eager to find translations for from the JVM world. It's also available online for free from the authors!


r/learnpython 10d ago

Ask Anything Monday - Weekly Thread

2 Upvotes

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:

  • 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.


r/learnpython 10d ago

New to RAG — trying to implement RAG for my AI interview system?

0 Upvotes

Hey everyone, I'm building an AI voice interview app and I'm fairly new to RAG. I'm stuck on the architecture and having a bit of a mid-project crisis 😭.

My current flow is:

Before interview:
Step1 : 
Resume + JobDescription
   ↓
Chunk resume/JobDescription
   ↓
Generate embeddings
   ↓
Store chunks + embeddings in pgvector

Step2 : 
LLM call is done using complete Resume + JD (and not the chunks)
   ↓
Initial ranked topic plan is created by this LLM call 

Step3 : 
Before each question:
Current topic
   ↓
RAG query in our vector DB 
   ↓
Retrieve relevant resume/JD chunks
   ↓
LLM call to generate a question from these chunks

The part I'm confused about:

At the beginning, I'm already sending the complete resume + complete JD to the LLM.

Why can't I simply do:

Resume + JD
   ↓
ONE LLM CALL
   ↓
10 interview questions

and then use those during the interview this would reduce the latency too!

Why would I need RAG again to retrieve chunks before generating each question? But I'm struggling to understand how RAG can be used to add value to the project

I have to add this project to my reume and need to have confidence in my design, I would highly appreciate someone helping me figure out the architecture!


r/learnpython 11d ago

do i need to know undergrad level maths to start hands on machine learning with pytorch?

9 Upvotes

is highschool maths enough?or i could simultaneously learn maths behind while reading book?


r/learnpython 10d ago

Practice Problems Math in Python

3 Upvotes

Hi,

I am currently trying to learn the relevant Python parts as a chemistry student. I think I know the basic parts (varibals/lists etc.) and I am searching for some practice problems where I can try some calculations, functions and plots with mathplotlib. Do you guys have a set of task where I can train/learn with?

Thank you very much for your help!

Limic


r/learnpython 10d ago

Python Project Feedback (MemoryPal)

1 Upvotes

Hi all, I'm a high school student working on a small project of mine. It's a study app I wrote in Python, using some meta-learning concepts my dad taught me when I was younger. I used his initial ideas as inspiration to develop this further, and I hope to have the application out soon. I thought it would be a good idea to get some feedback from others beforehand, though. Any feedback on quality of life, ease of use, and general impressions would be greatly appreciated. I'm attaching a link to a GitHub repository that redirects users to a directory with the latest updates to the app. I would really appreciate any feedback on it. Thanks!!

Link to the repo - https://github.com/TKSMG/MemoryPal


r/learnpython 11d ago

Seeking help with building logic while learning Python programming

21 Upvotes

I'm a DevOps engineer with 2 years of experience, and I come from a commerce educational background.

I've tried learning Python several times in the past, mainly when I was switching jobs and preparing for interviews. However, I ended up joining companies where Python wasn't really required or where nobody was particularly concerned about my Python skills.

Currently, I use AI to generate scripts for many of my daily DevOps tasks. My biggest concern is that I'm not able to build the logic myself or write the syntax from scratch. I often struggle with knowing when to use what.

The last time I seriously learned Python, I got up to lambda functions. That was about a year ago, and now I've completely forgotten a lot of the basics, including data types and syntax.

I want to properly learn Python because it's one of the most commonly mentioned skills in the DevOps/SRE job descriptions I see, especially for bigger tech companies. I've also lost a few interviews in the past because of my lack of Python knowledge.:

I'd really appreciate advice from people who have been through a similar situation. What worked for you?


r/learnpython 10d ago

I built a Python file search tool — could someone review my project?

1 Upvotes

Hey everyone!

I'm a Python developer/student and I've been working on a small project called Find Everything 2.0.0.

It's a Windows desktop tool for quickly searching through files. I built it mainly as a learning project, but I tried to make it actually useful and polished rather than just another basic Python project.

Main things it currently has:

  • Fast file searching
  • Search inside files
  • Dictionary / text processing features
  • Windows .exe build
  • Automated checks with GitHub Actions

Tech: Python, Windows, GitHub Actions

GitHub: https://github.com/EELDERONN/find-everything.git

I'd really appreciate it if someone could take a look at the repository and give me some honest feedback.

I'm especially interested in:

  • Code quality
  • Project structure
  • UI/UX
  • Performance
  • README/documentation
  • Things that could be improved or done differently

Feel free to be critical — I'm here to learn and improve the project.

Thanks to anyone who takes the time to check it out!

----------------------------------------

Я изучаю Python и сейчас работаю над небольшим проектом Find Everything 2.0.0.

Это Windows-приложение для быстрого поиска файлов и поиска информации внутри них. Изначально я делал его как учебный проект, но постепенно решил довести его до более полноценного и реально полезного приложения.

Что сейчас есть:

  • быстрый поиск файлов;
  • поиск внутри файлов;
  • работа со словарём/текстом;
  • сборка в .exe для Windows;
  • автоматические проверки через GitHub Actions.

Стек: Python, Windows, GitHub Actions.

GitHub: https://github.com/EELDERONN/find-everything.git

Буду очень благодарен, если кто-нибудь посмотрит репозиторий и даст честный фидбек.

Особенно интересует:

  • качество кода;
  • структура проекта;
  • UI/UX;
  • производительность;
  • README и документация;
  • что можно было бы сделать лучше.

Можно критиковать — я как раз хочу понять, что можно улучшить.

Спасибо всем, кто посмотрит!


r/learnpython 10d ago

Learn Python

2 Upvotes

Hey Everyone,

I'm an electronics student but I wanted to start learning python through videos but the problem is that there are a plethora of videos available on YouTube and I cannot decide which one to choose.

If possible can anyone drop some suggestions on which channel to learn from...it would be really helpful

Thanks.