Python

[ follow ]
Python
fromRealpython
2 hours ago

Break Out of Loops With Python's break Keyword - Real Python

The break statement immediately exits the innermost loop, stopping further iterations; continue skips the current iteration but does not exit the loop.
Python
fromPyImageSearch
3 weeks ago

Build a VLC Playlist Generator with SmolVLM for Video Highlight Tagging - PyImageSearch

A VLC Playlist Generator uses SmolVLM2 to detect video highlights and generate XSPF playlists for direct navigation in VLC.
#fastapi
fromRealpython
1 day ago
Python

How to Serve a Website With FastAPI Using HTML and Jinja2 Quiz - Real Python

Builds dynamic websites using FastAPI and Jinja2 by returning HTML, serving static files, rendering templates with context, and adding CSS/JavaScript interactivity.
fromPyImageSearch
1 day ago
Python

FastAPI Docker Deployment: Preparing ONNX AI Models for AWS Lambda - PyImageSearch

Build and containerize a FastAPI AI inference server serving an ONNX model with image preprocessing and Docker deployment, preparing for AWS Lambda serverless deployment.
#kv-cache
fromPyImageSearch
1 month ago
Python

Introduction to KV Cache Optimization Using Grouped Query Attention - PyImageSearch

Grouped Query Attention reduces KV cache memory by letting multiple query heads share fewer KV heads, lowering memory use with minimal accuracy loss.
fromPyImageSearch
1 month ago
Python

KV Cache Optimization via Multi-Head Latent Attention - PyImageSearch

Multi-head Latent Attention compresses per-head KV tensors into shared low-rank latents, cutting KV cache memory and compute while preserving attention quality.
fromPyImageSearch
1 week ago

Converting a PyTorch Model to ONNX for FastAPI (Docker) Deployment - PyImageSearch

In this lesson, you will learn how to convert a pre-trained ResNetV2-50 model using PyTorch Image Models (TIMM) to ONNX, analyze its structure, and test inference using ONNX Runtime. We'll also compare inference speed and model size against standard PyTorch execution to highlight why ONNX is better suited for lightweight AI inference. This prepares the model for integration with FastAPI and Docker, ensuring environment consistency before deploying to AWS Lambda.
Python
fromPyImageSearch
1 month ago

Building a Streamlit Python UI for LLaVA with OpenAI API Integration - PyImageSearch

In this tutorial, you'll learn how to build an interactive Streamlit Python-based UI that connects seamlessly with your vLLM-powered multimodal backend. You'll write a simple yet flexible frontend that lets users upload images, enter text prompts, and receive smart, vision-aware responses from the LLaVA model - served via vLLM's OpenAI-compatible interface. By the end, you'll have a clean multimodal chat interface that can be deployed locally or in the cloud - ready to power real-world apps in healthcare, education, document understanding, and beyond.
Python
Python
fromNedbatchelder
2 days ago

Why your mock breaks later

Patch mocks where the object is used, not where it's defined, to avoid unintended, global effects on other libraries and test infrastructure.
fromMathspp
1 day ago

Floodfill algorithm in Python

ctx = canvas.getContext("2d") URL = "/blog/floodfill-algorithm-in-python/_python.txt" async def load_bitmap(url: str) -> list[list[int]]: # Fetch the text file from the URL response = await fetch(url) text = await response.text() bitmap: list[list[int]] = [] for line in text.splitlines(): line = line.strip() if not line: continue row = [int(ch) for ch in line if ch in "01"] if row: bitmap.append(row) return bitmap
Python
Python
fromMedium
1 week ago

How to activate virtual environment in python3

Use virtual environments to avoid pip 'externally-managed-environment' errors and prevent altering the system Python or other projects' dependencies.
Python
fromPythonbytes
4 days ago

Tapping into HTTP

Tools and techniques: httptap for detailed HTTP timing, Python performance hacks to speed code, and FastRTC for real-time Python audio/video streaming.
Python
fromInfoWorld
4 days ago

Python vs. Mojo (and Java, Go, Rust, and .NET)

Mojo, alternative data-science languages, Python dataclasses, and a new PyTorch-related distributed-processing framework are current focal points for Python practitioners.
Python
fromMicrosoft for Python Developers Blog
4 days ago

Python in Visual Studio Code - November 2025 Release - Microsoft for Python Developers Blog

Python extension November 2025 adds Copilot 'Add as docstring', localized hover summaries, Convert wildcard imports code action, and debugger support for multiple interpreters.
Python
fromPythonmorsels
6 days ago

Unnecessary parentheses in Python

Parentheses in Python serve three roles—calling callables, creating empty tuples, and grouping—while grouping can be optional, misplaced, or enable implicit line continuation.
Python
fromEfficient Coder
1 week ago

The Anatomy of a Scalable Python Project | EfficientCoder

Organize Python projects with a balanced folder structure, centralized config, fast tests, and predictable boundaries to scale code, team, environments, and speed.
Python
frompythontest.com
1 week ago

Explore Python dependencies with `pipdeptree` and `uv pip tree`

pipdeptree and uv pip tree reveal Python package dependency trees; pipdeptree runs with --python auto while uv pip tree integrates with uv-managed virtual environments.
fromdaniel.feldroy.com
1 week ago

Visiting Tokyo, Japan from November 12 to 24

I'm excited to announce that me and Audrey will be visiting Japan from November 12 to November 24, 2025! This will be our first time in Japan, and we can't wait to explore Tokyo. Yes, we'll be in Tokyo for most of it, near the Shinjuku area, working from coffee shops, meeting some colleagues, and exploring the city during our free time.
Python
Python
fromRealpython
1 week ago

Python Operators and Expressions - Real Python

Python operators enable computation and data manipulation using arithmetic, comparison, Boolean, identity, membership, bitwise, concatenation, repetition, and augmented assignment operators.
fromNedbatchelder
1 week ago

Three releases, one new organization

To measure your code, coverage.py needs to know what code got executed. To know that, it collects execution events from the Python interpreter. CPython now has two mechanisms for this: trace functions and sys.monitoring. Coverage.py has two implementations of a trace function (in C and in Python), and an implementation of a sys.monitoring listener. These three components are the measurement cores, known as "ctrace", "pytrace", and "sysmon".
#mcp
fromThepythoncodingstack
1 week ago

The Misunderstood Hashable Types and Why Dictionaries Are Called Dictionaries * [Club]

Pick up a dictionary. No, not that one. The real dictionary you have on your bookshelf, the one that has pages made of paper, which you use to look up the meaning of English words. Or whatever other language. But let's assume it's an English dictionary. Now, look up zymology. I'll wait... Done? It probably didn't take you too long to find zymology.
Python
#python-314
Python
fromPythontest
1 month ago

Testing against Python 3.14 | PythonTest

Update projects to test against Python 3.14 and adjust local installs, tox, classifiers, and CI test matrices accordingly.
Python
fromPythonbytes
1 month ago

pi py-day (or is it py pi-day?)

Python 3.14 introduces PEP 750 and PEP 758, improved errors, a default interactive shell with syntax highlighting and autocompletion, and several tooling enhancements.
Python
fromRealpython
1 week ago

Episode #273: Advice for Writing Maintainable Python Code - The Real Python Podcast

Use clear comments, expressive names, avoid magic numbers, design for future changes, and adopt modern tooling (like Ruff) to make Python code maintainable and refactorable.
fromRealpython
1 week ago

Python MarkItDown: Convert Documents Into LLM-Ready Markdown - Real Python

The MarkItDown library lets you quickly turn PDFs, Office files, images, HTML, audio, and URLs into LLM-ready Markdown. In this tutorial, you'll compare MarkItDown with Pandoc, run it from the command line, use it in Python code, and integrate conversions into AI-powered workflows. By the end of this tutorial, you'll understand that: You can install MarkItDown with pip using the specifier to pull in optional dependencies.
Python
fromTreehouse Blog
1 week ago

From Excel to Python: A Beginner's Guide

Excel gives you a huge toolbox of functions ( SUM, IF, VLOOKUP, INDEX, etc.), but eventually, you hit a wall. Maybe you want to do something more custom than Excel allows. Maybe your file slows down with too many rows. Or maybe there simply isn't a built-in function for exactly what you need. Python solves this by letting you build your own custom functions. That's why it's so powerful for data analysis-it's Excel without limits.
Python
#__slots__
#open-source
Python
The Python Software Foundation withdrew a $1.5M NSF grant proposal because funding conditions required denying support for diversity across all PSF activities.
#lazy-imports
Python
fromMathspp
1 week ago

A generator, duck typing, and a branchless conditional walk into a bar

Generators provide lazy evaluation in Python, enabling iterable objects like range to create values on demand and avoid upfront computation.
Python
fromMedium
3 weeks ago

From Chaos to Coordination: The Power of Multi AI Agent Systems with CrewAI

CrewAI uses multiple specialized AI agents organized into crews and processes to manage complex, multi-step projects more reliably than a single AI.
Python
fromPythonbytes
2 weeks ago

Gilded Python and Beyond

Cyclopts replaces Typer's proxy-default CLI design with annotations to fix usability issues, while Python 3.14's free-threaded interpreter reduces GIL-related penalties to about 5–10%.
Python
fromRealpython
2 weeks ago

Using Python Optional Arguments When Defining Functions Quiz - Real Python

Understand Python parameter handling: default values, mutable-default pitfalls, argument unpacking (*args/**kwargs), and using Boolean flags for clearer function calls.
Python
fromPythontest
3 weeks ago

Polite lazy imports for Python package maintainers | PythonTest

Minimize package import time by lazily loading subcomponents via __init__.py so importing the package doesn't load unused parts.
fromRealpython
2 weeks ago

Episode #272: Michael Kennedy: Managing Your Own Python Infrastructure - The Real Python Podcast

How do you deploy your Python application without getting locked into an expensive cloud-based service? This week on the show, Michael Kennedy from the Talk Python podcast returns to discuss his new book, "Talk Python in Production." Michael runs multiple Python applications online, including a training site, blog, and two podcasts. While searching for the best solution for hosting his business, he documented his findings in a book.
Python
Python
fromDEV Community
3 weeks ago

Scratching the Itch, Paying the Debt: How Community Keeps Legacy Open Source Projects Alive

FastKML and PyGeoIf grew from personal tools into widely used geospatial Python libraries that now need modernization due to technical debt and ecosystem changes.
Python
fromQuansight
2 weeks ago

Exploring & Improving the Thread Safety of NumPy's Test Suite

NumPy's test suite was improved for thread-safety to prepare for free-threaded Python by fixing tests, updating CI, and applying OSS practices.
Python
fromAntocuni
2 weeks ago

Inside SPy, part 1: Motivations and Goals - Antonio Cuni's blog

SPy is a statically typed Python variant combining an interpreter and compiler focused on performance, deliberately sacrificing full Python compatibility for optimization.
Python
fromPycon
2 weeks ago

PyCon US 2026 - Call for Proposals Now Open!

PyCon US 2026 will take place in Long Beach, CA, May 13–19, 2026, with the Call for Proposals and website now open.
Python
fromPythonmorsels
2 weeks ago

__dict__: where Python stores attributes

Python stores attributes for instances, classes, and modules in their __dict__ dictionaries, mapping attribute names to values.
Python
fromESPN.com
2 weeks ago

Nebraska's black alternate uniforms headline best Week 10 threads in college football

Nebraska will wear a monochromatic black uniform with a white helmet featuring a black "N" emblem when No. 23 USC visits in Week 10.
Python
fromMathspp
3 weeks ago

TIL 135 - Build the Python documentation

Fixing a single leading-space in a reStructuredText comment corrected a misrendered 'See also' callout in Python documentation.
Python
fromThepythoncodingstack
3 weeks ago

Impostors * How Even The Python Docs Get This Wrong* * [Club]

zip(), enumerate(), and range() are common Python loop tools; mastering them enables exploring itertools, and examples of range() in for loops can be misleading.
fromGrahamdumpleton
3 weeks ago

Detecting object wrappers - Graham Dumpleton

The best example of this and the reason that wrapt was created in the first place, is to instrument existing Python code to collect metrics about its performance when run in production. Since one cannot expect a customer for an application performance monitoring (APM) service to modify their code, as well as code of the third party dependencies they may use, transparently reaching in and monkey patching code at runtime is the best one can do.
Python
fromRubyflow
3 weeks ago

Resolving the 'rest_framework' Module Not Found Error

The ModuleNotFoundError: No module named 'rest_framework' is a common issue faced by developers working with Django REST Framework (DRF).
fromRealpython
3 weeks ago

What Can I Do With Python? Quiz - Real Python

How well do you know the different areas where Python shines? In this quiz, you'll revisit web apps and APIs, GUI apps, CLI tools, machine learning, and more. You'll also check what Python isn't suited for and which alternatives work better. Get ready to explore the wide scope of what you can do with Python.
Python
fromInfoWorld
3 weeks ago

How to use Python dataclasses

Everything in Python is an object, or so the saying goes. If you want to create your own custom objects, with their own properties and methods, you use Python's class object to do it. But creating classes in Python sometimes means writing loads of repetitive, boilerplate code; for example, to set up the class instance from the parameters passed to it or to create common functions like comparison operators.
Python
fromPythonbytes
4 weeks ago

It's some form of Elvish

caniscrape checks a website for common anti-bot mechanisms and reports: A difficulty score (0-10) Which protections are active (e.g., Cloudflare, Akamai, hCaptcha, etc.) What tools you'll likely need (headless browsers, proxies, CAPTCHA solvers, etc.) Whether using a scraping API might be better This helps you decide the right scraping approach before you waste time building a bot that keeps getting blocked.
Python
Python
fromReuven Lerner
4 weeks ago

Your personal mentor for Python and Pandas

LernerPython.com delivers structured, mentored Python, Pandas, and Git training with courses, exercises, live mentorship, community lectures, and member perks.
#wrapt
fromTalkpython
4 weeks ago

38 things Python developers should learn in 2025

Free-threaded CPython (PEP 703): A build mode that removes the GIL so CPU-bound threads can run in parallel. Expect ecosystem work to make C extensions safe here. (Python Enhancement Proposals (PEPs)) uv and uvx: A faster, modern installer and environment manager that makes "clean, repeatable" installs feel instant. (Astral Docs) Docker + Compose: Containers capture your app and its services so dev and prod stay in sync. (Docker Documentation)
Python
Python
fromThepythoncodingstack
4 weeks ago

Are Tuples More Like Lists or Strings? And Why We Don't Really Care * [Club]

Choose Python data types based on semantic meaning and intended usage, not superficial similarity; tuples serve different roles than lists or strings in code design.
fromhttps://daniel.feldroy.com
4 weeks ago

Using Asyncpg with FastAPI and Air

Asyncpg is the connector for PostgreSQL and asyncio-flavored Python. Here's how to use it without other libraries on FastAPI and Air projects. Recently I've been on a few projects using PostgreSQL where SQLAlchemy and SQLModel felt like overkill. Instead of using those libraries I leaned on writing SQL queries and running those directly in [asyncpg](https://pypi.org/project/asyncpg/) instead of using an ORM powered by asyncpg. Here's how I got it to work
Python
Python
fromPythonbytes
1 month ago

Python++

New Python ecosystem tools and projects include PyPI+ for package exploration, uv-ship for safer releases, performance analysis of Python 3.14, and the experimental Air framework.
Python
fromInfoWorld
1 month ago

7 newer data science tools you should be using with Python

Several lesser-known Python data-wrangling tools, including ConnectorX and DuckDB, enable faster, parallelized database loading and in-process OLAP analytics beyond Pandas/Numpy.
fromRealpython
1 month ago

Polars vs pandas: What's the Difference? Quiz - Real Python

Interactive Quiz ⋅ 10 QuestionsBy Ian Eyre
Python
fromThepythoncodingstack
1 month ago

Creating a Singleton Class in Python And Why You (Probably) Don't Need It

If you spend long enough in the programming world, you'll come across the term singleton at some point. And if you hadn't seen this term yet, well, now you have! In Python, you don't need singleton classes. Almost never. But creating one is a great exercise in understanding how Python creates objects. And discussing alternatives to a singleton class helps you explore other aspects of Python.
Python
fromRealpython
1 month ago

Python Descriptors - Real Python

Descriptors are a specific Python feature that power a lot of the magic hidden under the language's hood. If you've ever thought that Python descriptors are an advanced topic with few practical applications, then this video course is the perfect tool to help you understand this powerful feature. You'll come to understand why Python descriptors are such an interesting topic and discover the kinds of use cases where you can apply them.
Python
Python
fromMedium
1 month ago

If You Write Python, You Must Understand Asyncio

asyncio is Python's built-in library enabling asynchronous programming with async/await, allowing concurrent task progress during I/O waits.
Python
fromRealpython
1 month ago

How to Use Python: Your First Steps - Real Python

Python installs on Windows, macOS, and Linux, offers a readable syntax, built-in data types, error handling, interactive REPL, and tools to start programming effectively.
Python
fromRealpython
1 month ago

How to Use Python: Your First Steps Quiz - Real Python

Practice Python fundamentals—variables, keywords, strings, and error recognition—through an eight-question, untimed quiz with scored feedback.
fromStreamHacker
1 month ago

Monitoring Celery Tasks with Sentry

Sentry is a great tool for monitoring celery tasks, and alerting when they fail or don't run on time. But it requires a bit of work to setup properly. Below is some sample code for setting up sentry monitoring of periodic tasks, followed by an explanation. import math import sentry_sdk from celery import signals from sentry_sdk import monitor from sentry_sdk.integrations.celery import CeleryIntegration @signals.beat_init.connect # if you use beats @signals.celeryd_init.connect def init_sentry(**kwargs): sentry_sdk.init( dsn=..., integrations=[ CeleryIntegration(monitor_beat_tasks=False) ] ) @signals.worker_shutdown.connect @signals.task_postrun.connect def flush_sentry(**kwargs): sentry_sdk.flush(timeout=5) def add_periodic_task(celery, schedule, task): max_runtime = math.ceil(schedule * 4 / 60) monitor_config = { "recovery_threshold": 1, "failure_issue_threshold": 10, "checkin_margin": max_runtime, "max_runtime": max_runtime, "schedule": { "type": "interval", "value": math.ceil(schedule / 60.0) "unit": "minute" } } name = task.__name__ task = monitor(monitor_slug=name, monitor_config=monitor_config)(task) celery.add_periodic_task(schedule, celery.task(task).s(), name=name)
Python
Python
fromPythontest
1 month ago

Installing Python 3.14 on Mac or Windows | PythonTest

uv enables clean, convenient installation and management of multiple Python versions; python.org installers remain a simple choice for single-version users.
Python
fromTall, Snarky Canadian
1 month ago

Why it took 4 years to get a lock files specification

A lock file must unambiguously record where and how to obtain and install every dependency, handling source trees, sdists, wheels, specifiers, and dependency graphs.
Python
fromMicrosoft for Python Developers Blog
1 month ago

Python in Visual Studio Code - October 2025 Release - Microsoft for Python Developers Blog

October 2025 Python extensions for VS Code add Python Environments fixes, Copy Test ID testing workflow, and shell startup improvements for environment activation.
fromTreyhunner
1 month ago

Handy Python REPL Modifications

I find myself in the Python REPL a lot. I open up the REPL to play with an idea, to use Python as a calculator or quick and dirty text parsing tool, to record a screencast, to come up with a code example for an article, and (most importantly for me) to teach Python. My Python courses and workshops are based largely around writing code together to guess how something works, try it out, and repeat.
Python
Python
fromPeterbe
1 month ago

In Python, you have to specify the type and not rely on inference - Peterbe.com

TypeScript infers literal argument types causing compile-time errors for mismatched values; Python's mypy requires explicit annotations to report the same mismatches.
fromTheregister
1 month ago

Python 3.14 released with cautious free-threaded support

Free threading in Python, which disables the global interpreter lock (GIL), is now a complete implementation of PEP (Python Enhancement Proposal) 703, a much anticipated feature which makes concurrent programming in Python natural. Free-threaded mode also enables a specialized adaptive interpreter, originally part of the Faster CPython project led by Mark Shannon at Microsoft (though the company axed its support in May).
Python
Python
frompythontest.com
1 month ago

pytest 2.6.0 release

pytest-check 2.6.0 makes check.raises() return an object with a .value property so exception values can be inspected like pytest.raises().
Python
fromBitcoin Magazine
1 month ago

Brazil's OranjeBTC Goes Public, Boosts LATAM Bitcoin Push

OranjeBTC listed on Brazil's B3 as a corporate vehicle centered on holding 3,675 BTC, becoming Latin America's largest corporate Bitcoin holder.
fromMathspp
1 month ago

Functions: a complete reference | Pydon't

Do not overcrowd your functions with logic for four or five different things. A function should do a single thing, and it should do it well, and the name of the function should clearly tell you what your function does. If you are unsure about whether some piece of code should be a single function or multiple functions, it's best to err on the side of too many functions. That is because a function is a modular piece of code, and the smaller your functions are, the easier it is to compose them together to create more complex behaviours.
Python
Python
fromDEV Community
1 month ago

Python Code Quality Tools Beyond Linting

Combining fast unified linting with specialized architectural and metric tools enables predictive, empirically validated technical-debt risk assessment and prioritized refactoring.
Python
fromMathspp
1 month ago

TIL 134 - = alignment in string formatting

The '=' alignment puts the sign left and digits right; a leading zero width uses '=' and pads the number with zeros.
fromRealpython
1 month ago

Episode #268: Advice on Beginning to Learn Python - The Real Python Podcast

What's changed about learning Python over the last few years? What new techniques and updated advice should beginners have as they start their journey? This week on the show, Stephen Gruppetta and Martin Breuss return to discuss beginning to learn Python. We share techniques for finding motivation, building projects, and learning the fundamentals. We provide advice on installing Python and not obsessing over finding the perfect editor. We also examine incorporating LLMs into learning to code and practicing asking good questions.
Python
Python
fromInfoWorld
1 month ago

PDM: A smarter way to manage Python packages

PDM recomputes dependency graphs after changes; use pdm list or pdm list --graph, pdm install or pdm sync to install; PDM doesn't mark dev/optional packages.
[ Load more ]