r/Python • u/AffectionateYak7537 • 1h ago
Resource Tell me what python code to mess a round
Type a random python code in the comments to mess around for a flight that’s coming up soon and I really wanna mess a round with some python cod
r/Python • u/AutoModerator • 1d ago
Dive deep into Python with our Advanced Questions thread! This space is reserved for questions about more advanced Python topics, frameworks, and best practices.
Let's deepen our Python knowledge together. Happy coding! 🌟
r/Python • u/AffectionateYak7537 • 1h ago
Type a random python code in the comments to mess around for a flight that’s coming up soon and I really wanna mess a round with some python cod
r/Python • u/quiet_stacktrace • 4h ago
i keep going back and forth between a .env file loaded with python-dotenv, a pydantic settings class, and plain os.environ lookups. for a small project with one dev and one prod environment, what has actually held up for you? mostly curious how you deal with secrets and defaults without it turning into a mess after a year.
r/Python • u/Nausicaa23Pencil • 5h ago
I've been adding strict=True to quite a few zip() calls in our codebase and ran into a subtle distinction that's worth keeping in mind.
Consider something like:
for user, email in zip(users, emails, strict=True):
send_email(user, email)If the iterables have different lengths, Python will raise a ValueError. But by that point you might have already sent hundreds of emails.
Obviously this is consistent with how lazy iteration works. Still, I think the name "strict" can give a slightly misleading sense of safety when you're reading code that performs side effects.
For small inputs, materializing the zipped pairs before processing them solves this particular issue. For large streams, things get more interesting.
I've started distinguishing between validation that happens before processing and validation that happens during processing when reviewing iterator-heavy Python code.
Are there other standard library features where this distinction has caught you out?
r/Python • u/AdMammoth8075 • 13h ago
Hey everyone, I just published my first C++ powered Python library on PyPI (kaptandanuj-easyhelper) to see how much faster list operations get when you move the loop from Python to C++.
Right now it has an order-preserving unique() function for int, float, and str lists. Under the hood it uses a templated C++ std::vector + std::unordered_set with reserve() pre-allocation, bound with pybind11.
On a list of 100k items, it beats a normal Python for loop + set()
Here how you install it
pip install kaptandanuj-easyhelper
r/Python • u/Pharaoh_Bellhop8 • 1d ago
I inherited a bunch of internal Python scripts at work last year. Most of them were perfectly readable, did their job and had been running for years without any major issues.
The annoying part was figuring out what they'd actually done.
One would print "Done" whether it processed 400 files or found nothing to process. Another would silently skip invalid records. To understand the result of a successful run I sometimes had to read the source code.
I've since developed a habit of ending even fairly trivial scripts with a small summary of what was found, what changed, what was skipped and why.
It's probably the smallest change I've made to my coding habits with the biggest practical payoff. Especially when revisiting something I wrote six months ago.
I think we spend a disproportionate amount of time making Python code pleasant for other developers to read compared to making Python programs pleasant for other people to actually run.
r/Python • u/memameola • 1d ago
Hey r/Python! I wanted a way to automatically turn long YouTube videos into vertical 9:16 clips without paying for LLM APIs or running heavy PyTorch models on an old laptop.
How Max Clipper works under the hood:
- Explainable Clip Picking: Uses deterministic DSP and statistical heuristics (hook, audio energy, pacing, heatmap) instead of black-box LLMs—same input always gives the exact same output.
- Low-Spec Optimization: Built and tested on a 4th-gen Intel i5 with 8GB RAM and no GPU. Uses a global render lock to prevent FFmpeg CPU starvation, stall-based timeouts, and -preset ultrafast on <= 4 cores.
- Packaging: One-command installers for Linux/macOS/Windows plus Docker support.
Source Code (MIT License): https://github.com/4hmed1/MaxClipper
Would love code review or feedback on the clip-scoring heuristics!
r/Python • u/alexis_placet • 1d ago
Hi,
I'm sharing a blogpost about how we are now able to use PyTorch or Jax in your notebook in the browser ! : https://notebook.link/blog/train-in-your-tab/
Here some examples (be sure to use a WebGPU compatible browser):
r/Python • u/Ishannaik • 1d ago
I ship a desktop app with a python backend frozen with pyinstaller, currently unsigned. Two problems on Windows:
I'm about to pay for signing, and the part I can't find a straight answer on is the pyinstaller side:
If you've been through this, what did your build pipeline end up looking like?
r/Python • u/AutoModerator • 2d ago
Welcome to our weekly Project Ideas thread! Whether you're a newbie looking for a first project or an expert seeking a new challenge, this is the place for you.
Difficulty: Intermediate
Tech Stack: Python, NLP, Flask/FastAPI/Litestar
Description: Create a chatbot that can answer FAQs for a website.
Resources: Building a Chatbot with Python
Difficulty: Beginner
Tech Stack: HTML, CSS, JavaScript, API
Description: Build a dashboard that displays real-time weather information using a weather API.
Resources: Weather API Tutorial
Difficulty: Beginner
Tech Stack: Python, File I/O
Description: Create a script that organizes files in a directory into sub-folders based on file type.
Resources: Automate the Boring Stuff: Organizing Files
Let's help each other grow. Happy coding! 🌟
r/Python • u/AutoModerator • 3d ago
Hello r/Python! It's time to share what you've been working on! Whether it's a work-in-progress, a completed masterpiece, or just a rough idea, let us know what you're up to!
Let's build and grow together! Share your journey and learn from others. Happy coding! 🌟
r/Python • u/AutoModerator • 4d ago
Stumbled upon a useful Python resource? Or are you looking for a guide on a specific topic? Welcome to the Resource Request and Sharing thread!
Share the knowledge, enrich the community. Happy learning! 🌟
r/Python • u/Beginning-Fruit-1397 • 5d ago
Each time l see this sub it's about wathever package I don't use that got compromised which I couldn't care less about. Now that all code showcase are banned, the new ways for sloppers to feel seen is report security issues. At least the former was still related to code, cybersecurity is another thing completely. I'd rathet see slop code showcases than a boring report about x package hacked
r/Python • u/Business-Feedback635 • 5d ago
Python runs any line that starts with import in a .pth file in site-packages, every time it starts. You don't have to import the package. This year, the malicious releases of litellm (March and October) and agent-framework (November) all used a .pth file, so installing them was enough to run the credential stealer.
I wanted to see how many ordinary packages use the same feature. I took the latest release of 354,763 PyPI projects, found every .pth file with an import line, downloaded them and read them. The results:
.pth file that runs on every Python start.-nspkg.pth).urllib3 folder at startup.import lines (PEP 829), and 3.18 will ignore them. Only 13 of the 244 packages already ship the replacement .start file.The post includes a command that lists the .pth files with import lines in your own environment, and a table of what the 15 most downloaded ones do: https://py-code.org/blog/python-pth-files-pypi/
r/Python • u/AutoModerator • 5d ago
Welcome to Free Talk Friday on /r/Python! This is the place to discuss the r/Python community (meta discussions), Python news, projects, or anything else Python-related!
Let's keep the conversation going. Happy discussing! 🌟
r/Python • u/enterthearena44 • 6d ago
I was reading about yesterday's Microsoft Agent Framework security incident, and something caught my attention.
Apparently, attackers published two malicious versions (1.26.1 and 1.26.2) of Microsoft's official Python package on PyPI. These versions could steal cloud credentials just by starting Python.
Both versions were removed quickly.
What surprised me was that the malicious code wasn't even checked into Microsoft's GitHub repository.
From what I understand:
- Developers write code in GitHub.
- CI/CD builds it into a Python wheel (.whl).
- The wheel gets published to PyPI.
- When we run "pip install", we download that package.
But apparently, someone with the right publishing credentials can upload a malicious wheel directly, without going through the original GitHub repository.
That raises some interesting questions:
I'm still learning about software supply-chain security, so I'd love to hear how experienced Python developers and security engineers think this should work.
r/Python • u/AutoModerator • 6d ago
Welcome to this week's discussion on Python in the professional world! This is your spot to talk about job hunting, career growth, and educational resources in Python. Please note, this thread is not for recruitment.
Let's help each other grow in our careers and education. Happy discussing! 🌟
r/Python • u/OriginalHistorian522 • 7d ago
Hey everyone! If you’re a college student interested in Applied AI Engineering, Cybersecurity, Web Development, or Technical Interview Prep, check out CodePath’s free Spring 2027 courses.
I’m a Tech Fellow (TF) teaching Technical Interview Prep (TIP), and I highly recommend it if you want to learn data structures and algorithms in Python or get more comfortable with coding interviews. We practice breaking down problems, choosing the right data structure, and explaining our reasoning out loud. That last part makes a big difference when an interviewer asks you to walk through your approach.
If you’re interested, apply to CodePath here. That’s my referral link.
Happy to answer questions about TIP or what it’s like to take the course!
r/Python • u/BattleRemote3157 • 7d ago
1.26.1 and 1.26.2 both ship a credential stealer. It runs from a .pth file, so it executes at interpreter startup. Nothing has to import the package, a pip install in CI is enough. 1.26.1 got pulled, then 1.26.2 went up 33 minutes later with the same payload under different file names. Last clean release is 1.26.0.
complete details- https://safedep.io/blog/microsoft-agent-framework-pypi-compromise
r/Python • u/AutoModerator • 8d ago
Dive deep into Python with our Advanced Questions thread! This space is reserved for questions about more advanced Python topics, frameworks, and best practices.
Let's deepen our Python knowledge together. Happy coding! 🌟
r/Python • u/Impossible-Ad-6925 • 9d ago
What My Project Does
git-wrapped reads your local git history and gives you a "year in review": a colored contribution heatmap in your terminal, plus a shareable 1080x1350 card (SVG or PNG) with your commits, active days, longest streak, peak coding hour, top languages and a "persona" for your year (Night Owl, Early Bird, Weekend Warrior...).
It can scan a whole folder of repos at once and de-duplicates commits.
Target Audience
Any developer who wants a fun, shareable recap of their year. It's a hobby/side project, not production tooling.
Comparison
Many GitHub stats widgets rely on the GitHub API and a token. git-wrapped only runs `git log` locally, so it works offline, with private repos and non-GitHub repos, and it has no Python dependencies (PNG export uses a renderer you already have, like Chrome or rsvg-convert).
Usage
pip install git+https://github.com/Mohammadsdq/git-wrapped
git-wrapped ~/projects --year 2026 --png
My own year, for fun: 74 commits, peak hour 11pm, favorite commit word "upload" (10x). Apparently I'm a "Steady Builder".
Repo: Github Repo
r/Python • u/AutoModerator • 9d ago
Welcome to our weekly Project Ideas thread! Whether you're a newbie looking for a first project or an expert seeking a new challenge, this is the place for you.
Difficulty: Intermediate
Tech Stack: Python, NLP, Flask/FastAPI/Litestar
Description: Create a chatbot that can answer FAQs for a website.
Resources: Building a Chatbot with Python
Difficulty: Beginner
Tech Stack: HTML, CSS, JavaScript, API
Description: Build a dashboard that displays real-time weather information using a weather API.
Resources: Weather API Tutorial
Difficulty: Beginner
Tech Stack: Python, File I/O
Description: Create a script that organizes files in a directory into sub-folders based on file type.
Resources: Automate the Boring Stuff: Organizing Files
Let's help each other grow. Happy coding! 🌟
r/Python • u/Ashamed-Calendar-139 • 10d ago
Hey folks! I’ve been playing with agentic coding and wondering if it’s actually worth adding Python-specific skills to my setup.
For those of you using them: which ones are genuinely useful? Any examples where a Python-specific skill noticeably improved the result vs just letting the agent figure things out on its own?
r/Python • u/AutoModerator • 10d ago
Hello r/Python! It's time to share what you've been working on! Whether it's a work-in-progress, a completed masterpiece, or just a rough idea, let us know what you're up to!
Let's build and grow together! Share your journey and learn from others. Happy coding! 🌟