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.
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.
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.
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.
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)
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
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.
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.
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)
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.
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).
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.
Let's say we have some text that was retrieved from a database, and the original text came from a form submission in a web browser. Web browsers often represent line breaks as a carriage return character, followed by a line feed character: That's what we see in our text as well: \r followed by \n. This is often called CRLF (carriage return and line feed) whereas \n is called LF (line feed).
Villager, a new penetration-testing tool linked to a suspicious China-based company and described by researchers as "Cobalt Strike's AI successor," has been downloaded about 10,000 times since its release in July. The package, published on Python Package Index, operates as a Model Context Protocol (MCP) client and integrates multiple security tools. It includes Kali Linux, which legitimate defenders use to automate penetration testing, and it contains hundreds of tools that can also be used to launch cyber attacks at scale.
This quiz helps you practice sorting dictionaries by keys, values, and custom rules in modern Python. You'll revisit how insertion order works, when to use different views, and how to rebuild sorted dictionaries. You'll also learn best practices for sorting dictionaries efficiently. For a complete overview, check out Sorting Dictionaries: Keys, Values, and More. The quiz contains 11 questions and there is no time limit. You'll get 1 point for each correct answer.