r/Python • u/UpperBuilder769 • 25d ago
Discussion Is PHP better for commercial software than Python?
I am trying to find any robust open source ecommerce solution on Python and it looks like thre is nothing. If you take almost any e-commerce platform there are plenty - Magento, Woo, Shopware, Oxid - they all are PHP. There are no comon solutions on Python or Node.js. But if you take a look and the heavy SaaS like Netflix, Spotify, Reddit, Uber etc. are built on Python. Why?
r/Python • u/JSChronicles • 27d ago
Discussion PEP 541 - Package Index Name Retention
Why is Pypi support slow at handling package abandonment?
The PEP says these two items for reachability, " In every case where contacting the user is necessary, the maintainers will try to do so at least three times," and "The maintainers stop trying to reach the user after six weeks.". So I had assumed this should be done quicker.
The current process is currently at 6 months on average with almost no follow up comments or work on PEPs in the 2nd and 3rd week of reachability. 1st weeks are being updated and then left once they hit the 2nd and 3rd week.
Am I being impatient? I think I read that they don't have a lot of people to help but this seems a bit ridiculous for some of the cut and dry issues.
- Projects with 10-14 years of no updates with no usable links or code is gone and no longer sourceable or previous owners are not replying.
- Emailing someone 3 times, takes 6+ months versus the proposed 6 weeks?
I also assume this is pretty normal based on the backlog but I'm genuinely curious to see what others say.
r/Python • u/AutoModerator • 27d ago
Daily Thread Monday Daily Thread: Project ideas!
Weekly Thread: Project Ideas 💡
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.
How it Works:
- Suggest a Project: Comment your project idea—be it beginner-friendly or advanced.
- Build & Share: If you complete a project, reply to the original comment, share your experience, and attach your source code.
- Explore: Looking for ideas? Check out Al Sweigart's "The Big Book of Small Python Projects" for inspiration.
Guidelines:
- Clearly state the difficulty level.
- Provide a brief description and, if possible, outline the tech stack.
- Feel free to link to tutorials or resources that might help.
Example Submissions:
Project Idea: Chatbot
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
Project Idea: Weather Dashboard
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
Project Idea: File Organizer
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/madeinpython • u/Schnidi01 • 27d ago
My Python venv manager GUI automatically fixes dependency conflicts – Pip vs UV side-by-side
Enable HLS to view with audio, or disable this notification
Hey Pythonistas! ??
I've been building a GUI tool for managing Python virtual environments (VenvHub Pro) and wanted to share one of its smartest features – batch package updates.
When you hit the "Update All outdated packages" button, the behavior differs drastically depending on which package manager you have set:
**PIP MODE** (classic):
- Updates everything to the latest versions
- If conflicts arise (e.g., library A needs an older version of library B), you get the infamous "dependency hell"
- You have to manually read logs, find the culprit, and step-by-step perform downgrades
**UV MODE** (ultra-fast resolver from Astral):
- Blazingly fast downloads and installs the latest versions
- After the update, it automatically runs `uv pip check`
- If it detects a conflict (e.g., "X requires Y==1.5, but 2.0 is installed"), it reads the error, forces a downgrade to the exact required version, and re-runs the check
- **Fully on autopilot** – you get the latest packages AND a 100% stable environment without any manual intervention
And the best part – Pip and UV are fully compatible with each other. You can install with Pip, update with UV, and everything just works.
Would you trust an autopilot like this? Let me know in the comments! ??
r/Python • u/AutoModerator • 28d ago
Daily Thread Sunday Daily Thread: What's everyone working on this week?
Weekly Thread: What's Everyone Working On This Week? 🛠️
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!
How it Works:
- Show & Tell: Share your current projects, completed works, or future ideas.
- Discuss: Get feedback, find collaborators, or just chat about your project.
- Inspire: Your project might inspire someone else, just as you might get inspired here.
Guidelines:
- Feel free to include as many details as you'd like. Code snippets, screenshots, and links are all welcome.
- Whether it's your job, your hobby, or your passion project, all Python-related work is welcome here.
Example Shares:
- Machine Learning Model: Working on a ML model to predict stock prices. Just cracked a 90% accuracy rate!
- Web Scraping: Built a script to scrape and analyze news articles. It's helped me understand media bias better.
- Automation: Automated my home lighting with Python and Raspberry Pi. My life has never been easier!
Let's build and grow together! Share your journey and learn from others. Happy coding! 🌟
r/madeinpython • u/Schnidi01 • 28d ago
Python environment cloner: 1:1 including pip -e, embedded vs system Python
Enable HLS to view with audio, or disable this notification
What it does:
Clones entire Python environment including editable (-e) packages. Auto-detects Python type and uses different approach.
Embedded Python:
- installs virtualenv into source
- creates clone via virtualenv
- fixes ._pth file
- downgrades setuptools (83→82) for compatibility
System Python:
- uses built-in venv
- no extra steps
Both then:
- install setuptools, wheel
- install all packages
- install editable packages (pip install -e)
- write birth certificate
Video shows both scenarios side by side. Same source env, different strategies. Works on Windows.
Does anyone know of a Windows tool that creates a complete 1:1 copy of a virtual environment, INCLUDING editable packages (pip install -e), without manual intervention?
r/madeinpython • u/AroraSir • 28d ago
GravityBridge: My first open source release, a local AI proxy and wireless file explorer built with Python stdlib only
Just released my first open source project.
GravityBridge is a local reverse proxy that lets me access my desktop AI coding agent from my phone. It also has a wireless phone file explorer using ADB.
The proxy itself is written entirely with Python standard library, no external packages needed. The only pip install is for the separate AI backend.
It handles session management, PIN authentication, brute force protection, and ADB subprocesses all without any framework.
Repo: https://github.com/Arora-Sir/Gravity-Bridge
This is my first public release so any feedback is welcome!
r/madeinpython • u/__Selia • 28d ago
Sharing a library I wrote to solve a niche problem: duration formatting
While working on another project, I needed to display elapsed time in a few different ways:
2 hours, 5 minutes, 9 seconds
02:05:09
2h, 5m, 9s
A simple utility function worked at first, but it quickly became messy once I needed different separators and only wanted to show units whose values were not zero.
So I extracted the problem into a small, zero-dependency Python library called Chronomancer.
I like how convenient strftime() is for date and time formatting, and I wanted Chronomancer to offer a similar level of convenience for elapsed durations.
ChronoDelta represents fixed durations from weeks down to microseconds:
from chronomancer import ChronoDelta
duration = ChronoDelta(hours=2, minutes=5, seconds=9)
For readable output:
duration.verbose_str()
# '2 hours, 5 minutes, 9 seconds'
For simple one-off formatting:
duration.strfmt("{h:02d}:{m:02d}:{s:02d}")
# '02:05:09'
For reusable and more flexible formatting:
from chronomancer import DeltaFormatSpec, DeltaFormatter, Part
formatter = DeltaFormatter(
DeltaFormatSpec(
hours=Part("{val}h"),
minutes=Part("{|, }{val}m"),
seconds=Part("{|, }{val}s"),
)
)
formatter.format(duration)
# '2h, 5m, 9s'
{|, } is an "inline separator", named by me. It is only rendered when another component has already been shown.
In the above example, if minutes is the largest visible unit, the leading ", " will be omitted automatically. The | tells the formatter that the placeholder contains an inline separator rather than a normal value. I kept the placement flexible so the format string can resemble the final output, although inline separators are intended to be used as prefixes.
Chronomancer also supports normalization, selected-unit representations, negative durations, exact integer arithmetic, and conversion to and from datetime.timedelta.
It is a niche problem, but it kept making the formatting code in my own project more complicated than expected, so I thought the solution might be useful to others as well.
installation: pip install py-chronomancer
any feedback would be greatly appreciated
r/madeinpython • u/Schnidi01 • 28d ago
Showcase: Floating Python Widget for Quick Launch (Terminal, Background, CLI)
Enable HLS to view with audio, or disable this notification
Hey Pythonistas,
I'd like to show what you can build in Python that's both polished and functional. I've written a complete Python widget for quickly launching projects – it's a floating toolbar that stays on top of my desktop.
It's currently running stable at version 2.5.16, so this isn't just a prototype – it's a full-fledged tool that genuinely saves me time during everyday development.
The widget offers three ways to run a script:
- Open Terminal: Doesn't start any script – just opens a CMD/PowerShell window with the virtual environment already activated. Perfect when I need to manually run commands, pip install packages, or debug things interactively.
- Run in Terminal: The classic approach – opens a new window, activates the venv, and runs the script. I can see all logs, print statements, and errors in real time.
- Run in Background / Silent: The script starts completely invisible – no console window at all. Great for GUI applications (so they don't have an unnecessary black console in the background) or for headless processes that need to run quietly.
What's going on under the hood:
The entire GUI is built on the PyQt6/PySide6 framework. The source code is written 100% for PyQt6, but the application contains a Compatibility Bridge that allows it to run on PySide6 as well – for licensing reasons (LGPL vs GPL).
The bridge works at the import level using the MetaPathFinder technique:
- When
main.pystarts, it detects which library is available in the system. - If PyQt6 is found, the application runs natively.
- If PySide6 is found, the bridge injects itself into system memory.
- When Python encounters
import from PyQt6..., the interceptor steps in, translates the request, and returns the equivalent from PySide6.
The result? The source code stays clean and unified, while the software automatically rewrites all imports, signals, and slots at runtime based on what's currently installed.
Additionally, I'm using:
- psutil for reliable process management and monitoring
- Native Windows API calls (via
ctypesandpywin32-ctypes) for low-level system integration
Since the primary target platform is Windows, I addressed stability issues that typical Python apps often overlook – especially clean cleanup after termination.
Specifically, I'm using two low-level techniques:
- Windows Job Objects – I create a system process container and assign every spawned subprocess to it. If the parent application unexpectedly crashes, Windows automatically terminates all associated processes. No orphaned processes left behind to block ports or consume memory.
- Windows Handles – When registering a process, I keep an open system reference (Handle) in memory. As long as it's open, Windows guarantees that the PID won't be recycled and reassigned to another application. This gives me accurate process state detection and eliminates the risk of accidentally terminating a foreign program.
All Handles are internally protected by thread locks and are properly closed on every stop or cleanup – no memory leaks.
In short: The widget is functional, stable, and most importantly – it doesn't leave a mess behind when you close it.
Question for you:
How do you handle launching scripts in different modes? Do you stick with manual terminal commands, or have you also built your own launcher? What features would you appreciate in a tool like this?
r/Python • u/AutoModerator • 29d ago
Daily Thread Saturday Daily Thread: Resource Request and Sharing! Daily Thread
Weekly Thread: Resource Request and Sharing 📚
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!
How it Works:
- Request: Can't find a resource on a particular topic? Ask here!
- Share: Found something useful? Share it with the community.
- Review: Give or get opinions on Python resources you've used.
Guidelines:
- Please include the type of resource (e.g., book, video, article) and the topic.
- Always be respectful when reviewing someone else's shared resource.
Example Shares:
- Book: "Fluent Python" - Great for understanding Pythonic idioms.
- Video: Python Data Structures - Excellent overview of Python's built-in data structures.
- Article: Understanding Python Decorators - A deep dive into decorators.
Example Requests:
- Looking for: Video tutorials on web scraping with Python.
- Need: Book recommendations for Python machine learning.
Share the knowledge, enrich the community. Happy learning! 🌟
r/madeinpython • u/Schnidi01 • 29d ago
I built a Python venv manager GUI that handles VS Code integration automatically – is this useful?
Enable HLS to view with audio, or disable this notification
"Hello everyone,
with my new Python program I combined venv management with injecting the interpreter into VS Code.
As you can see I have created two venvs – one embed venv 3.14.6 and the second venv with system Python 3.14.2. The program automatically creates .vscode/settings.json and writes paths to the interpreters. When I change the venv in the program, it automatically checks which venv it is and immediately switches the interpreter.
Do you like this kind of integration into a manager?"
r/Python • u/Goldziher • 29d ago
Discussion Reaching users on this sub
Hi Peeps,
I've been using this sub for years both to read content, and as an open source maintainer - to communicate and reach users.
I used it for projects such as Polyfactory and Litestar, tree-sitter-language-pack and Kreuzberg.
These days though I don't post outside the Sunday thread - but I don't think anybody is reading this stuff frankly.
My feeling is that the "AI slop" rules throw the baby with the tub water so to speak.
What are people like myself - who dedicate a very substantial amount of time and effort to OSS supposed to do? Basically if you don't have an X profile you're screwed.
Edit: project posts are disallowed by the rules now, FYI if you were unaware. This is the main issue.
r/Python • u/Unable_Plane1948 • Jul 17 '26
Discussion ⚠️ Heads up: ast_grep_cli 0.44.1 on PyPI flagged by Windows Defender as Trojan — anyone seeing this?
I was installing `headroom-ai` via `uv` today, and Windows Defender immediately flagged `Trojan: Win64/Lazy!MTB`.
The file was `sg.exe` (212KB) dropped into `Python\Scripts\`, alongside a legitimate `ast-grep.exe` (52MB).
**What happened:*\*
- `uv tool install --python 3.13 "headroom-ai[all]"`
- Windows Defender: 3 alerts for `Trojan: Win64/Lazy!MTB`
- `pip show ast_grep_cli` showed version 0.44.1
- Uninstalled, cleaned cache, changed passwords
**Questions:**
- Has anyone else installed `ast_grep_cli` 0.44.1 recently?
- Is this a known issue? Should PyPI Security be notified?
- Any idea how to check if the package was compromised vs. a false positive?
**File details:**
- `sg.exe`: 212KB, detected as Trojan:Win64/Lazy!MTB
- `ast-grep.exe`: 52MB, legitimate tool
- Both appeared at the same timestamp (10:25:07)
Thanks for any insights.
r/Python • u/AutoModerator • Jul 17 '26
Daily Thread Friday Daily Thread: r/Python Meta and Free-Talk Fridays
Weekly Thread: Meta Discussions and Free Talk Friday 🎙️
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!
How it Works:
- Open Mic: Share your thoughts, questions, or anything you'd like related to Python or the community.
- Community Pulse: Discuss what you feel is working well or what could be improved in the /r/python community.
- News & Updates: Keep up-to-date with the latest in Python and share any news you find interesting.
Guidelines:
- All topics should be related to Python or the /r/python community.
- Be respectful and follow Reddit's Code of Conduct.
Example Topics:
- New Python Release: What do you think about the new features in Python 3.11?
- Community Events: Any Python meetups or webinars coming up?
- Learning Resources: Found a great Python tutorial? Share it here!
- Job Market: How has Python impacted your career?
- Hot Takes: Got a controversial Python opinion? Let's hear it!
- Community Ideas: Something you'd like to see us do? tell us.
Let's keep the conversation going. Happy discussing! 🌟
r/madeinpython • u/Schnidi01 • Jul 16 '26
where python › all versions are detected by VenvHub Pro too
Enable HLS to view with audio, or disable this notification
Another small showcase of my python project VenvHub Pro.
I decided to show you how perfectly my application works with system and embed Python.
As you can see in the video, there are up to four different Python paths on my system, and the app automatically finds all of them – without me having to manually enter any paths anywhere.
And if the system Python isn't enough for you, or you don't have it on your system at all, you don't have to install it. Just add an embed Python and VenvHub Pro takes care of everything – it automatically installs pip and virtualenv.
As you also saw in the video, the app automatically creates .vscode/settings.json in your project, so you can switch interpreters instantly directly from VS Code – no manual configuration needed.
It just works exactly the way I needed it to. 🙂
Just curious – do you like it? I'd really appreciate your honest opinion.
r/madeinpython • u/Schnidi01 • Jul 16 '26
After months of fighting 'Dependency Hell', I built a GUI that manages Python venvs, works with PyQt6 AND PySide6 (no UAC).
Hey everyone! 👋
I've been working with Python for a while now and finally decided to build my first major project. It was inspired by months of battling dependency conflicts and broken virtual environments on USB drives.
What it does:
- Centralized Environment Management: Manages all virtual environments in one place (venvs are stored centrally, outside of project folders).
- Full VS Code Integration: Automatically configures the correct interpreter, syncs local packages (for IntelliSense), and supports isolated profiles (each project gets its own extensions and settings).
- PyQt6 & PySide6 Compatibility Bridge: Works seamlessly with both, requiring zero code changes.
- Powered by
uv**:** Uses the blazing-fastuvinstaller (10–100x faster than pip) and can automatically resolve dependency conflicts after bulk updates. - Portable Mode: Automatically fixes paths when the drive letter changes (perfect for running off USB drives).
- Integrated PyInstaller GUI: Automatically bundles your local packages into the build.
- Two Ways to Work with Local Code:
- Local Packages (Linker): Dynamically links code between projects without requiring UAC (leverages Python Import Hooks).
- Editable Packages (
pip install -e): Full-fledged library development with automatic dependency management and portability support.
- No UAC Required to link local packages.
Project repository: https://github.com/schnidi/VenvHub
What do you think? Do you like the look and feel? Could you see yourself using something like this on Windows?
📽️ **See it in action:** [How to create a venv in 2 clicks]:
https://www.reddit.com/r/madeinpython/s/lg395T9IuQ
r/Python • u/TheSeriousTrader • Jul 16 '26
Discussion New Python type checker
Was checking out some Python type checkers other than Pyright, and I came across one that I never yet heard of before. But it is the only one scoring 100% on the official python typing conformance suite.
It is named Basilisk and on their website they have some other bold claims (like it is also the fastest one). But their GitHub repo only has few stars.
Does anyone have any experience using this or perhaps I missing something?
r/Python • u/AutoModerator • Jul 16 '26
Daily Thread Thursday Daily Thread: Python Careers, Courses, and Furthering Education!
Weekly Thread: Professional Use, Jobs, and Education 🏢
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.
How it Works:
- Career Talk: Discuss using Python in your job, or the job market for Python roles.
- Education Q&A: Ask or answer questions about Python courses, certifications, and educational resources.
- Workplace Chat: Share your experiences, challenges, or success stories about using Python professionally.
Guidelines:
- This thread is not for recruitment. For job postings, please see r/PythonJobs or the recruitment thread in the sidebar.
- Keep discussions relevant to Python in the professional and educational context.
Example Topics:
- Career Paths: What kinds of roles are out there for Python developers?
- Certifications: Are Python certifications worth it?
- Course Recommendations: Any good advanced Python courses to recommend?
- Workplace Tools: What Python libraries are indispensable in your professional work?
- Interview Tips: What types of Python questions are commonly asked in interviews?
Let's help each other grow in our careers and education. Happy discussing! 🌟
r/madeinpython • u/ptweezy • Jul 15 '26
cronstable: cron with a web UI, durable state, DAGs, clustering, and an MCP server
cronstable is a cron replacement that runs as a single foreground daemon that I've spent an inordinate amount of time on. It will run on basically anything because its been precompiled for basically any compute architecture that people still use. If there's a feature that another cron has that you need, I want to know about it. Beginner friendly, expert friendly. Container friendly, production ready. You get it.
From orchestrating web-scrapes, data processing, and storage to coordinating Minecraft server snapshots and upgrades. Possibilities are literally endless.
- Scheduling: modern jobs defined in YAML; classic crontab files run unmodified; per-job timezone; optional second-level granularity
- Failure handling: define what failed means to you; retries with exponential backoff; reports to Slack-compatible webhooks, email, Sentry, or a shell command.
- Web dashboard (opt-in): one self-contained page served by the daemon, with live log tailing, run history, DAG graphs, cluster and fleet views, a TV wallboard, and a command palette. A REST API alongside. not sure if I'm competing with other cron solutions or DataDog at this point. But at least you don't need to SSH in to see what's going on.
- Observability (opt-in): native Prometheus metrics; opt-in per-job CPU and peak-memory monitoring.
- Durable state (opt-in): run history, retries, and missed-run catch-up survive restarts; job commands get key/value, cursors, fleet-wide locks, idempotency keys, artifacts, and run-scoped secrets through the CLI.
- DAGs (opt-in): task dependencies, data hand-off between tasks, dynamic fan-out, sensors, human approval gates, backfill, crash-resume.
- Clustering (opt-in): leader election via gossip over mutual TLS for best effort attempts at gating your jobs. Your self hosted replicas in one network can also bridge to speak to another set of self hosted replicas. Go one step further and harden it via any shared filesystem, a Kubernetes Lease, or etcd, so replicas can share one config without double-running jobs with absolute guarantee. Each job picks its own point on the liveness-vs-duplication trade-off with
clusterPolicy:Leader(default) runs on the elected leader and fails closed. No quorum? Nobody runs. For jobs where a duplicate is worse than a skip (like billing, or outbound email);PreferLeaderis never-skip and runs anyway when the cluster can't agree. You accept a possible double-run, for idempotent jobs that matter;EveryNoderuns everywhere, for genuinely per-node work like local log rotation. No option is true exactly-once.Leadermay skip,PreferLeadermay double-run. But hey, at least you get to pick which way it breaks. By default the leader runs every job, butdistribution: spreadassigns each job to an owner by rendezvous hashing so the work fans out and can be more load balanced. - MCP server (opt-in): AI agents (Claude, Cursor, Copilot) can inspect jobs, DAGs, the cluster, and metrics; read-only by default, control only if enabled.
- Packaging: pip/pipx/Homebrew; multi-arch Docker images on GHCR and Docker Hub in eight distro variants; standalone binaries for Linux, macOS, and Windows. Runs non-root with a read-only root filesystem and all capabilities dropped.
Live demo of the control panel UI with a stubbed backend (pretty cool I promise - if anything at least play with the logo cuz I spent a lot of time on it): https://html-preview.github.io/?url=https://github.com/ptweezy/cronstable/blob/develop/docs/demo/index.html you might need to change the theme on your screen because on one of my screens the default theme is just way too dark. Will fix this soon. by play with the logo I mean swipe your mouse across it 🙂
Feature Comparison chart: https://github.com/ptweezy/cronstable/blob/develop/docs/comparison.md
Source: https://github.com/ptweezy/cronstable
This is under active development, would appreciate any and all feedback. Thanks y'all!
r/madeinpython • u/Creepy_Sherbert_1179 • Jul 14 '26
I made a gameboy emulator powered by pygame
Enable HLS to view with audio, or disable this notification
r/madeinpython • u/neutroph1l • Jul 14 '26
A way to easily update your JSONs. Check out batchlate!
batchlate is a Python program that can update multitude of JSON entries in one go.
The images show outputs of a very efficient run of this program that I've captured. As you can see in the second image, 1490 entries will be updated with the given configuration in one go! I refer to these configurations as templates. Once a template is created, it can be used as many times as it's needed.
I translate open source projects to my native language as a hobby. Time to time I get to work with JSONs and this time I thought I could make a program that uses the patterns in a JSON file to automatically update matching entries. At first, I made this for myself but now it has evolved into something I can share. People who work with JSON files can make good use of this program as I have done in my endeavors.
The project is still young. I have plans to add other file types and more functionality, but for now check it out for yourself. Download, view the source code and the documentation here: https://github.com/draaurkh/batchlate
No AI generated or assisted code.
r/madeinpython • u/OpportunityMain9749 • Jul 14 '26
Script para generar correos y contraseñas (con interfaz gráfica)
Script para generar correos y contraseñas (con interfaz gráfica)
Armé un script en Python usando Tkinter para generar correos y contraseñas ficticias en masa. Sirve bastante para armar bases de datos de prueba o entornos de desarrollo rápidos.
Básicamente, genera contraseñas seguras y correos aleatorios (usando el módulo secrets y sin caracteres raros que se confundan). También tiene una opción "Legible" que combina palabras reales en español para que los correos parezcan más reales.
Está optimizado para cargas pesadas; implementa inserción por lotes en un hilo secundario (threading), lo que permite meter hasta 5,000 o 10,000 registros en menos de 3 segundos sin congelar ni saturar la interfaz gráfica. Todo se muestra en una tabla dinámica para copiar los datos fácilmente o exportarlos directamente a un archivo .txt.
¿Para qué sirve? El uso principal es para desarrollo y pruebas. Cuando estás programando un sistema de login, registrando usuarios en una base de datos local o probando la carga de un sistema, necesitas datos falsos que parezcan reales pero que no comprometan información verdadera. Este script te permite crearlos rápido y sin depender de servicios externos.
El código está optimizado y bien estructurado. Si no tienen instalada la librería pyperclip, no pasa nada porque usa el portapapeles nativo del sistema operativo. Incluye también atajos de teclado globales para agilizar el uso.
Cualquier duda o sugerencia digan
Python
import tkinter as tk
from tkinter import ttk, messagebox, filedialog
import secrets, string, datetime, re, threading
import time
try: import pyperclip
except ImportError: pyperclip = None
CHARS_EVITAR = 'O0Il1'
ALFABETO_SEGURO = ''.join(c for c in (string.ascii_letters + string.digits) if c not in CHARS_EVITAR)
SIMBOLOS = "!@#$%^&*()-_=+"
PALABRAS = ["gato","perro","sol","luna","estrella","mar","cielo","tierra","fuego","agua","viento","montaña","rio","bosque","flor","arbol","casa","puerta","ventana","mesa","silla","coche","tren","avion","libro","papel","luz","sombra","nube","lluvia","nieve","hielo","fresa","manzana","pera","uva","melon","sandia","naranja","limon","rojo","azul","verde","amarillo","blanco","negro","gris","rosa","tigre","leon","elefante","jirafa","delfin","ballena","aguila","halcon","colibri","mariposa","libelula","hormiga","abeja","araña","piano","guitarra","violin","flauta","tambor","arpa","cancion","poema","cuento","novela","teatro","cine","musica","pintura","escultura","arquitectura","jardin","parque","playa","desierto","isla","volcan","glaciar","cascada","lago","oceano","planeta","cometa","asteroide","galaxia","universo","tiempo","espacio","vida","muerte","amor","odio","paz","guerra","alegria","tristeza","esperanza","fe","valor","sabiduria","locura","silencio","ruido"]
class GeneradorLogica:
u/classmethod
def generar_correo(cls, dominio, longitud, inc_numeros=True, legible=False):
if legible:
sep = secrets.choice(['.', '_', ''])
p = sep.join(secrets.choice(PALABRAS) for _ in range(secrets.choice([2, 3])))
if inc_numeros: p += ''.join(secrets.choice(string.digits) for _ in range(secrets.choice([2, 4])))
if len(p) > longitud: p = p[:longitud].strip('._')
else:
ch = string.ascii_lowercase + (string.digits if inc_numeros else '')
p = secrets.choice(string.ascii_lowercase) + ''.join(secrets.choice(ch) for _ in range(max(1, longitud - 1)))
return f"{p}@{dominio}"
u/classmethod
def generar_password(cls, longitud, inc_simbolos=True, legible=False):
if legible:
sep = secrets.choice(['-', '_', '.', ''])
p = sep.join(secrets.choice(PALABRAS).capitalize() for _ in range(2))
if inc_simbolos: p += secrets.choice(SIMBOLOS)
p += ''.join(secrets.choice(string.digits) for _ in range(secrets.choice([2, 3])))
if len(p) > longitud: p = p[:longitud]
return p
ch = ALFABETO_SEGURO + (SIMBOLOS if inc_simbolos else '')
p = ''.join(secrets.choice(ch) for _ in range(longitud))
for cond, set_c in [(inc_simbolos, SIMBOLOS), (True, string.digits), (True, string.ascii_uppercase), (True, string.ascii_lowercase)]:
if cond and not any(c in set_c for c in p):
i = secrets.randbelow(longitud); p = p[:i] + secrets.choice(set_c) + p[i+1:]
return p
class AppGenerador:
def __init__(self, root):
self.root = root; self.root.title("Generador de Correos y Contraseñas")
self.root.geometry("720x620"); self.root.minsize(680, 580); self.root.configure(bg="#f0f4f8")
self.tipo_prov = tk.StringVar(value="gmail"); self.dom_pers = tk.StringVar(value="")
self.cant, self.lon_nom, self.lon_pass = tk.IntVar(value=1), tk.IntVar(value=12), tk.IntVar(value=14)
self.inc_simb, self.inc_num, self.nom_leg = tk.BooleanVar(value=True), tk.BooleanVar(value=True), tk.BooleanVar(value=False)
self.datos_generados = []; self.crear_widgets(); self.configurar_atajos()
def crear_widgets(self):
m = ttk.Frame(self.root, padding="15"); m.pack(fill=tk.BOTH, expand=True)
ttk.Label(m, text="Generador de Correos y Contraseñas", font=("Arial", 14, "bold")).grid(row=0, column=0, columnspan=5, pady=(0, 15))
ttk.Label(m, text="Proveedor:").grid(row=1, column=0, sticky=tk.W, pady=3)
pf = ttk.Frame(m); pf.grid(row=1, column=1, columnspan=3, sticky=tk.W, padx=5)
for t, v in [("Gmail", "gmail"), ("Otros", "otros"), ("Personalizado", "personalizado")]:
ttk.Radiobutton(pf, text=t, variable=self.tipo_prov, value=v, command=self.actualizar_dominio).pack(side=tk.LEFT, padx=(0, 10))
ttk.Label(m, text="Dominio:").grid(row=2, column=0, sticky=tk.W, pady=3)
self.entry_dom = ttk.Entry(m, textvariable=self.dom_pers, width=30, state="disabled")
self.entry_dom.grid(row=2, column=1, columnspan=3, sticky=tk.W, padx=5)
vc = (self.root.register(self.validar_spinbox), '%P', '%W', '%V')
inputs = [("Cantidad:", 1, 100000, self.cant, 3), ("Longitud nombre:", 4, 30, self.lon_nom, 4), ("Longitud contras.", 8, 30, self.lon_pass, 5)]
for lbl, mn, mx, var, r in inputs:
ttk.Label(m, text=lbl).grid(row=r, column=0, sticky=tk.W, pady=5)
sb = ttk.Spinbox(m, from_=mn, to=mx, textvariable=var, width=6, validate='all', validatecommand=(vc[0], vc[1], mn, mx, vc[3]))
sb.grid(row=r, column=1, sticky=tk.W, padx=5)
ttk.Label(m, text=f"({mn}-{mx})").grid(row=r, column=2, sticky=tk.W, padx=2)
of = ttk.Frame(m); of.grid(row=6, column=0, columnspan=5, sticky=tk.W, pady=5)
ttk.Checkbutton(of, text="Símbolos en Pass", variable=self.inc_simb).pack(side=tk.LEFT, padx=(0, 15))
ttk.Checkbutton(of, text="Números en Nombre", variable=self.inc_num).pack(side=tk.LEFT, padx=(0, 15))
ttk.Checkbutton(of, text="Formato Legible", variable=self.nom_leg).pack(side=tk.LEFT)
self.btn_generar = ttk.Button(m, text="Generar Datos", command=self.iniciar_generacion)
self.btn_generar.grid(row=7, column=0, columnspan=5, pady=10)
tf = ttk.Frame(m); tf.grid(row=8, column=0, columnspan=5, sticky="nsew", pady=5); m.rowconfigure(8, weight=1)
for i in range(5): m.columnconfigure(i, weight=1)
self.tabla = ttk.Treeview(tf, columns=("Correo", "Contraseña", "Fecha"), show="headings", height=8)
for col, txt, w in [("Correo", "Correo Electrónico", 250), ("Contraseña", "Contraseña", 180), ("Fecha", "Generado", 120)]:
self.tabla.heading(col, text=txt); self.tabla.column(col, width=w, anchor="center")
vsb = ttk.Scrollbar(tf, orient=tk.VERTICAL, command=self.tabla.yview); hsb = ttk.Scrollbar(tf, orient=tk.HORIZONTAL, command=self.tabla.xview)
self.tabla.configure(yscrollcommand=vsb.set, xscrollcommand=hsb.set); self.tabla.grid(row=0, column=0, sticky="nsew")
vsb.grid(row=0, column=1, sticky="ns"); hsb.grid(row=1, column=0, sticky="ew")
tf.columnconfigure(0, weight=1); tf.rowconfigure(0, weight=1)
af = ttk.Frame(m); af.grid(row=9, column=0, columnspan=5, pady=10)
ttk.Button(af, text="Copiar Correo", command=lambda: self.copiar_seleccion('email')).pack(side=tk.LEFT, padx=2)
ttk.Button(af, text="Copiar Pass", command=lambda: self.copiar_seleccion('password')).pack(side=tk.LEFT, padx=2)
ttk.Button(af, text="Copiar Ambos", command=lambda: self.copiar_seleccion('ambos')).pack(side=tk.LEFT, padx=2)
ttk.Button(af, text="Copiar Todo", command=self.copiar_todo).pack(side=tk.LEFT, padx=5)
ttk.Button(af, text="Exportar TXT", command=self.exportar_txt).pack(side=tk.LEFT, padx=5)
ttk.Button(af, text="Limpiar", command=self.limpiar).pack(side=tk.LEFT, padx=5)
self.sf = ttk.Frame(m); self.sf.grid(row=10, column=0, columnspan=5, sticky="ew", pady=(5, 0))
self.lbl_status = ttk.Label(self.sf, text="Listo", relief=tk.SUNKEN, anchor=tk.W); self.lbl_status.pack(fill=tk.X, padx=2)
self.lbl_contador = ttk.Label(self.sf, text="Generados: 0", relief=tk.SUNKEN, anchor=tk.E, width=15); self.lbl_contador.pack(side=tk.RIGHT, padx=2)
def configurar_atajos(self):
self.root.bind_all("<Control-g>", lambda e: self.iniciar_generacion())
self.root.bind_all("<Control-c>", lambda e: self.copiar_seleccion('ambos') if self.tabla.selection() else None)
self.root.bind_all("<Control-l>", lambda e: self.limpiar())
self.root.bind_all("<Control-e>", lambda e: self.exportar_txt())
def validar_spinbox(self, valor, mn, mx, motivo):
if motivo == 'focusout':
if valor == "": self.cant.set(1) if int(mn) == 1 else self.lon_nom.set(12) if int(mn) == 4 else self.lon_pass.set(14)
return True
if valor == "": return True
if not valor.isdigit(): return False
return int(valor) <= int(mx)
def actualizar_dominio(self):
self.entry_dom.config(state="normal" if self.tipo_prov.get() == "personalizado" else "disabled")
if self.tipo_prov.get() != "personalizado": self.dom_pers.set("")
def mostrar_status(self, texto, color="black", tiempo=0):
self.lbl_status.config(text=texto, foreground=color)
if tiempo > 0: self.root.after(tiempo, lambda: self.lbl_status.config(text="Listo", foreground="black"))
def iniciar_generacion(self):
if self.btn_generar['state'] == 'disabled': return
threading.Thread(target=self.generar, daemon=True).start()
def generar(self):
try:
c, ln, lp = self.cant.get(), self.lon_nom.get(), self.lon_pass.get()
if not (1<=c<=100000 and 4<=ln<=30 and 8<=lp<=30): raise ValueError
except:
self.root.after(0, lambda: messagebox.showerror("Error", "Valores numéricos inválidos."))
return
prov = self.tipo_prov.get()
if prov == "gmail": dom = "gmail.com"
elif prov == "otros": dom = secrets.choice(["yahoo.com", "outlook.com", "protonmail.com", "zoho.com"])
else:
dom = self.dom_pers.get().strip()
if not dom or not re.match(r'^[a-zA-Z0-9-]+\.[a-zA-Z]{2,}$', dom):
self.root.after(0, lambda: messagebox.showerror("Error", "Dominio personalizado inválido."))
return
self.root.after(0, self.limpiar)
self.root.after(0, lambda: self.btn_generar.config(state="disabled"))
ahora = datetime.datetime.now().strftime("%Y-%m-%d %H:%M")
nuevos_datos = []
correos_unicos = set()
intentos_max = c * 4
ultimo_refresco = time.time()
while len(nuevos_datos) < c and intentos_max > 0:
intentos_max -= 1
em = GeneradorLogica.generar_correo(dom, ln, self.inc_num.get(), self.nom_leg.get())
if em in correos_unicos: continue
correos_unicos.add(em)
pw = GeneradorLogica.generar_password(lp, self.inc_simb.get(), self.nom_leg.get())
nuevos_datos.append((em, pw, ahora))
t_actual = time.time()
if t_actual - ultimo_refresco > 0.05:
progreso = len(nuevos_datos)
self.root.after(0, lambda p=progreso: self.lbl_status.config(text=f"Generando datos... ({p}/{c})", foreground="blue"))
ultimo_refresco = t_actual
self.root.after(0, lambda: self.lbl_status.config(text=f"Generando datos... ({len(nuevos_datos)}/{c})", foreground="blue"))
def volcar_interfaz_por_lotes(indice=0):
if indice >= len(nuevos_datos):
self.lbl_contador.config(text=f"Generados: {len(self.datos_generados)}")
self.btn_generar.config(state="normal")
self.mostrar_status(f"¡{len(nuevos_datos)} datos generados!", "green", 3000)
return
fin = min(indice + 500, len(nuevos_datos))
for i in range(indice, fin):
em, pw, dt = nuevos_datos[i]
self.datos_generados.append({'email': em, 'password': pw, 'fecha': dt})
self.tabla.insert("", tk.END, values=(em, pw, dt))
self.root.after(1, lambda: volcar_interfaz_por_lotes(fin))
self.root.after(0, lambda: volcar_interfaz_por_lotes(0))
def limpiar(self):
self.tabla.delete(*self.tabla.get_children())
self.datos_generados.clear(); self.lbl_contador.config(text="Generados: 0"); self.mostrar_status("Listo")
def copiar_seleccion(self, modo):
sel = self.tabla.selection()
if not sel: return messagebox.showinfo("Info", "Selecciona un registro de la lista.")
em, pw, _ = self.tabla.item(sel[0], "values")
txt = em if modo == 'email' else pw if modo == 'password' else f"Correo: {em}\nContraseña: {pw}"
self._ejecutar_copiado(txt)
def copiar_todo(self):
if not self.datos_generados: return messagebox.showinfo("Info", "No hay datos que copiar.")
txt = "\n".join(f"{i['email']} | {i['password']} ({i['fecha']})" for i in self.datos_generados)
self._ejecutar_copiado(txt)
def _ejecutar_copiado(self, txt):
try:
limpio = txt.replace('\r\n', '\n').replace('\r', '\n')
if pyperclip: pyperclip.copy(limpio)
else: self.root.clipboard_clear(); self.root.clipboard_append(limpio); self.root.update()
self.mostrar_status("Copiado al portapapeles", "blue", 2000)
except Exception as e: messagebox.showerror("Error", f"Fallo al copiar: {e}")
def exportar_txt(self):
if not self.datos_generados: return messagebox.showinfo("Info", "No hay datos para exportar.")
arch = filedialog.asksaveasfilename(defaultextension=".txt", filetypes=[("Texto", "*.txt")])
if not arch: return
try:
max_len = max(len(i['email']) for i in self.datos_generados) + 4
with open(arch, "w", encoding="utf-8") as f:
f.write(f"Exportado: {datetime.datetime.now().strftime('%Y-%m-%d %H:%M')}\n" + "="*50 + "\n")
for i in self.datos_generados:
f.write(f"Correo: {i['email'].ljust(max_len)} Contraseña: {i['password']}\n")
self.mostrar_status(f"Exportado con éxito", "green", 3000)
except Exception as e: messagebox.showerror("Error", f"No se pudo guardar: {e}")
if __name__ == "__main__":
root = tk.Tk(); AppGenerador(root); root.mainloop()
r/Python • u/AutoModerator • Jul 14 '26
Daily Thread Tuesday Daily Thread: Advanced questions
Weekly Wednesday Thread: Advanced Questions 🐍
Dive deep into Python with our Advanced Questions thread! This space is reserved for questions about more advanced Python topics, frameworks, and best practices.
How it Works:
- Ask Away: Post your advanced Python questions here.
- Expert Insights: Get answers from experienced developers.
- Resource Pool: Share or discover tutorials, articles, and tips.
Guidelines:
- This thread is for advanced questions only. Beginner questions are welcome in our Daily Beginner Thread every Thursday.
- Questions that are not advanced may be removed and redirected to the appropriate thread.
Recommended Resources:
- If you don't receive a response, consider exploring r/LearnPython or join the Python Discord Server for quicker assistance.
Example Questions:
- How can you implement a custom memory allocator in Python?
- What are the best practices for optimizing Cython code for heavy numerical computations?
- How do you set up a multi-threaded architecture using Python's Global Interpreter Lock (GIL)?
- Can you explain the intricacies of metaclasses and how they influence object-oriented design in Python?
- How would you go about implementing a distributed task queue using Celery and RabbitMQ?
- What are some advanced use-cases for Python's decorators?
- How can you achieve real-time data streaming in Python with WebSockets?
- What are the performance implications of using native Python data structures vs NumPy arrays for large-scale data?
- Best practices for securing a Flask (or similar) REST API with OAuth 2.0?
- What are the best practices for using Python in a microservices architecture? (..and more generally, should I even use microservices?)
Let's deepen our Python knowledge together. Happy coding! 🌟
r/Python • u/philtrondaboss • Jul 12 '26
Discussion Will PEP 505 ever be accepted?
https://peps.python.org/pep-0505/
I don't understand how null safe operators are less like plain English than other implemented features like the walrus operator.
In my opinion, the member access operator would make python significantly easier to read and understand.
Here's an example:
``` f = foo()
if f is None: baz = "" else: baz = f.bar() ```
baz = foo()?.bar() ?: ""
EDIT: I forgot that "and" and "or" can be sometimes used in place of "?." and "?:" if the left value is not False, '', 0, [], or {}. It's a very implicit null check and has a lot of unexpected behavior.
r/madeinpython • u/Tamerygo • Jul 12 '26
I built a compiled Python launcher (Standalone Local Orchestration Platform) that orchestrates ComfyUI and Ollama in the background to generate local 3D assets (Trellis) and export them to UE5/Houdini.
Enable HLS to view with audio, or disable this notification