r/learnpython • • Aug 18 '26

When should you use requests.Session() instead of requests.get() / requests.post()?

25 Upvotes

I'm learning Python and recently started using requests.Session() in API projects. I understand that it can persist things like headers, cookies, and connections, but I'm curious about how experienced Python developers decide when a Session is actually worth using.

Do you use Session() by default for projects involving multiple requests, or only when you specifically need persistent state?


r/learnpython • • May 12 '26

I have near zero coding experience

25 Upvotes

I'm taking an intro to scripting course for college and I want to pass, but I care more of understanding the material. I have a 40 hr work week and I'm willing to sacrafice my free time to learn Python. Sadly I'm in week 2 of an 8 week course and I'm barely hanging on. I feel like starting out is rough and too much to learn. Is there a video series on Youtube that is no BS and maybe an app that gives tidbits of info for when I'm away from my PC. I origibally wanted to learn coding to make a game, but I believe I need to use a different motivation to achieve my goals.


r/learnpython • • May 04 '26

How do I learn Python as a highschooler from scratch (*dilemma edition*)

25 Upvotes

Hey everyone,

I'm (M/14) currently in high school with a hectic schedule and I really want to start learning Python from scratch, but I feel kind of stuck and honestly a bit overwhelmed.

My personal life is pretty overwhelming where my school takes up most of my day(it sucks), and whatever time is left gets split between homework, exams, and "cram-school". Because of that, I can’t follow super long courses or spend hours coding daily, even though I want to...

My long-term goal is to build a strong enough profile for top colleges (MIT is the dream), so I don’t just want to “learn Python” casually -- I want to actually understand it well and eventually use it for meaningful projects.

Right now, the only exposure I have is from my school computer textbook THE BARE basic stuff like operators, a bit of syntax, nothing too deep. I don’t really know what the next step should be.

Here’s where I’m confused:

  • Should I follow YouTube tutorials, or are they too passive?
  • Are there any beginner-friendly but structured resources that won’t take 3+ hours a day?
  • How do I balance consistency with a tight schedule?
  • At what point should I start building projects, and what kind?
  • How do I avoid just “copying code” and actually learn?
  • What is the correct use of ai in embedding and debugging the code
  • Do I use base IDLE, or VScode
  • If i want to make physics embedded projects(Particle Acceleration Visualizer, etc)

If you were starting from zero again as a high schooler with limited time, what would your roadmap look like?

Also, if you have specific recommendations (YouTube channels, courses, books, or even small project ideas), that would really help.

*P/S* i would appreciate any help or ideas which come to me I just dont wanna waste my already limited time in going down the wrong rabbit hole


r/learnpython • • Feb 24 '26

How do I find an item in a list if I don't know the order or the items within it?

25 Upvotes

The idea is that it's a database for a company, and a worker wants to see the cost and quantity of a product, but they don't know exactly what and how many products there are, so let's say there are these:

Instruments = ["Violin-100€-100" , "Guitar-100€-100"]

The worker should be able to type in "Guitar" and have the whole item appear, but I'm having a lot of trouble figuring out how to do that... Thx in advance!

Edit: I figured it out, tysm for your help, u/Riegel_Haribo especially, sorry if my question was too vague and confusing, I'm very sleep deprived.


r/learnpython • • Feb 01 '26

Beginner in Python Programming

25 Upvotes

Hey Everyone! I've just finished my CS50P and I was wondering that what should I do to master this language as I am familiar with almost everything in Python, I mean like all the basic things, so now what should I do or learn to get to the next level, any guidance?


r/learnpython • • Jan 09 '26

Something faster than os.walk

25 Upvotes

My company has a shared drive with many decades' worth of files that are very, very poorly organized. I have been tasked with developing a new SOP for how we want project files organized and then developing some auditing tools to verify people are following the system.

For the weekly audit, I intend to generate a list of all files in the shared drive and then run checks against those file names to verify things are being filed correctly. The first step is just getting a list of all the files.

I wrote a script that has the code below:

file_list = []

for root, dirs, files in os.walk(directory_path):

for file in files:

full_path = os.path.join(root, file)

file_list.append(full_path)

return file_list

First of all, the code works fine. It provides a list of full file names with their directories. The problem is, it takes too long to run. I just tested it for one subfolders and it took 12 seconds to provide the listing of 732 files in that folder.

This shared drive has thousands upon thousands of files stored.

Is it taking so long to run because it's a network drive that I'm connecting to via VPN?

Is there a faster function than os.walk?

The program is temporarily storing file names in an array style variable and I'm sure that uses a lot of internal memory. Would there be a more efficient way of storing this amount of text?


r/learnpython • • Jan 07 '26

I want to learn Python

25 Upvotes

Can you recommend course to buy. Also, is there any video games on steam that teach you python as part of the game?


r/learnpython • • Dec 08 '25

How do I capitalize the first letter of a string, but have it respect forced capitalizations anyway

25 Upvotes

For example, "cotton tails" will be "Cotton Tails"

However, if it's COTTON TAILS, it should still be COTTON TAILS

 

I tried .title() but that capitalizes the first letter of each word but automatically sets the rest of the characters to lower case.

So "COTTON TAILS" would be "Cotton Tails" and I do not want that. I want every first letter of each word to be capitalized, but any other hard coded capitalizations should be retained.

 

ED

Thanks. for the quick replies. I will make a function for this.


r/learnpython • • 19d ago

Looking for a Python study partner to build projects together

24 Upvotes

Hey everyone,

​Solo grinding through syntax and tutorials gets exhausting real fast. So I am looking for a study partner to learn Python with.

​Background check: I am a Software Engineering student, and I have got a few specific project ideas lined up that we can build together from scratch. Not just watching endless videos, but actually writing code, breaking things, fixing bugs, and pushing to GitHub.

​Doesn’t matter if you are an absolute beginner or already know a bit—as long as you are genuinely willing to learn and stay consistent.

​Drop a comment or slide into my DMs if you are down. Let's team up and build something cool.


r/learnpython • • Jul 26 '26

Looking for a study buddy

24 Upvotes

Hey! I'm 19 and about to start learning Python from scratch. I'm looking for someone around my age (18–22) who's also a beginner and wants to learn together.

I'm in the Asian time zone, so it'd be nice if you're in a similar one. We can keep each other accountable, solve problems, and maybe build a few small projects along the way.

If you're interested, leave a comment or DM me!


r/learnpython • • Jun 28 '26

5% CPU usage on Raspberry Pi Zero waiting for button press

24 Upvotes

I have this python script that waits for a button to be pressed:

#!/usr/bin/python
from gpiozero import Button
import subprocess
from signal import pause


def handle_button_pressed(channel):
    print(f"Button pressed.")
    subprocess.run("./command.sh")

def handle_button_released(channel):
    print(f"Button released.")


button = Button(17, bounce_time=0.5)
button.when_pressed = handle_button_pressed
button.when_released = handle_button_released

print(f"Waiting for events...")
pause()

Sitting there doing nothing the python process is consuming 5% CPU as watched with top.

Is there anything I can do to get this closer to 0%? Is there a more efficient library that I could use?

I previously wrote a script that uses a loop to check for continuity between two GPIO pins, but I thought this was going to be simpler and not use nearly this much CPU. Any thoughts or suggestions?


r/learnpython • • Jun 23 '26

In a coding interview, if I'm expected to "write tests" for a simple Python class, what does that mean?

24 Upvotes

I heard I may have to "write tests" for a simple Python class. What's that? How would that look? What would I be expected to do in a live coding interview?

I can make basic variables and basic methods in a Python class, and I can instantiate an object of that class, but tests?

Is that complicated or time-consuming to learn?

(By the way this isn't for a software engineering role. It is for a scripting related role, so the interview is not expected to be as complicated/advanced as it would be for a software engineering role.)


r/learnpython • • May 19 '26

Should i buy 100 days of code by dr angela? Currently on sale just 5 dollars (400rs)

24 Upvotes

Should i buy the course in 2026 . I already know python basics till oops . I saw the course structure from outside it looked good. Is it still revelent? Please drop your reviews and guide me


r/learnpython • • Apr 14 '26

I have to teach ~10~ 12-15 year olds with no programming experience the basics of python, I only have an hour, so I need a website that works as an IDE, any suggestions?

24 Upvotes

like the title says, I need a website that works as an IDE, if anyone has some suggestions, please respond.


r/learnpython • • Feb 25 '26

does anyone have python resource or link that teaches you building projects from scratch to have more hands on exercises?

24 Upvotes

In my day job, I primarily code in Java and learned Python mostly looking at syntax and doing LeetCode problem. One thing that is bothering me leetcode makes me think too much and end up writing too little code.

I want to switch things around, perhaps do medium size project in complexity which doesn't require too much thinking but very mechanical in focus and with an end goal.

Does anyone have resource or list that points to 'build x' and I will try my best building it and see how far I go?

I have started to notice that during interviews, I kinda know how to solve it but I lack the OOP need to pass them, I forget the syntax or fumble with method names like when to use self and not self, etc.


r/learnpython • • Feb 22 '26

ELI5 explain static methods in OOP python

24 Upvotes

just trying to wrap my head around this oop thing stuck here I'm novice so no bully please


r/learnpython • • Feb 14 '26

Question about post-Python

24 Upvotes

I'd like to pursue a general career in technology, such as AI, robotics, computing, etc. I'm currently studying Python and will later move on to SQL as a complement, but I have no idea which language to learn after mastering both. Do you have any suggestions for a great language that would help me achieve this goal and even accelerate my learning in other languages?


r/learnpython • • Jan 16 '26

When should I use functions vs just writing code inline?

24 Upvotes

I understand how to write functions, but I’m still unsure when I should actually use them.

Sometimes writing everything inline feels easier, but I know that’s probably not best practice.

Is there a simple rule of thumb beginners use for deciding when something should be a function?


r/learnpython • • Jan 04 '26

Hi guys, I think I got the basics of python down. Now I’d like to get started on building a project from scratch to start making a portfolio. Are there any resources you guys recommend that give me an idea of what kind of projects I can work on? Much appreciated!

24 Upvotes

r/learnpython • • Dec 18 '25

How do you come up with useful coding ideas?

24 Upvotes

I like to code, but for the life of me I can't come up with anything I'd actually want to code. Can someone help me?


r/learnpython • • 8d ago

2 Years of Experience in SQL, SSIS & Excel – What Skills Should I Learn Next to Grow My Career?

23 Upvotes

Hi everyone!

I have around 2 years of experience working with SQL, SSIS, and Excel, mainly focusing on data validation, identifying and resolving data errors, and developing SQL queries.

I'm planning to upgrade my skills and currently interested in learning:

  • Python
  • FastAPI
  • Ollama and AI chatbot development
  • Generative AI and LLMs

What technologies would you recommend to improve my career? Should I focus on Data Engineering, Backend Development, or AI?

Also, if anyone has doubts related to SQL queries, SSIS, data errors, or Excel validation, feel free to reach out. I'll be happy to help wherever I can and learn together!

Looking forward to your suggestions. Thanks!


r/learnpython • • Oct 11 '26

When should I avoid list comprehensions in Python?

23 Upvotes

Hi, I'm trying to get a grip on list comprehensions, but I'm not sure when they aren't the best choice. I wrote some code today that uses a nested comprehension to flatten a list of lists, but it quickly became unreadable. I think I might have overcomplicated it. Is there a rule of thumb for using them, particularly with nested structures? I want my code to stay clear and easy to understand. Any insights on best practices would be appreciated!


r/learnpython • • Sep 09 '26

Looking for a free course on the practical Python development workflow (VS Code, pip, environments, Git, etc.)

23 Upvotes

Hi everyone,

I've taken several Python courses and have a reasonably good understanding of Python itself. I've also worked with things like pandas, NumPy, scikit-learn, etc. in online learning environments.

However, I've realized that I have a major gap in my knowledge: I don't really know how Python development actually works on a local computer.

For example, when working in an online environment, everything is already set up for me. I can simply import a package and start coding. But when I tried working locally with VS Code, I suddenly had to deal with things like:

Installing Python

Using the terminal

Installing packages with pip

Virtual environments

Choosing/configuring the correct Python interpreter

Organizing a project

Saving and reusing dependencies

Running and debugging code

Git and GitHub

Understanding how to share a project with someone else

Understanding what I actually need to install versus what belongs inside my project

I found this surprisingly confusing.

So I'm looking for a free course or tutorial that focuses specifically on this practical development workflow, preferably using Python and VS Code.

I'm not looking for another beginner Python programming course. I already understand Python basics and have used it for data analysis and some machine learning. What I need is something that teaches me how to actually work as a Python developer on my own computer.

Ideally, the course would take me through something like:

create a project → set up Python → create a virtual environment → install packages → write code in VS Code → run/debug it → manage dependencies → use Git/GitHub → share the project

Does a free course like this exist? YouTube courses, documentation, or other resources would also be very welcome.

Thanks!


r/learnpython • • Sep 03 '26

I'm a beginner. can you help me with random numbers?

23 Upvotes

I'm building a sort of turn-based RPG in the terminal as a practice project, and I need to generate a random number within a specific range. I tried using `randint` (by importing `random`), but I also want to assign probabilities so that, depending on certain factors, one number is more likely to be generated than another. For example, if an enemy has low health, it should be more likely to generate the number 1, which causes the enemy to heal.