Real Python (@realpython) header
Real Python (@realpython) profile picture

Helping Python developers build with AI: apps, agents, models, and AI-assisted coding. Expert-reviewed tutorials and courses, read by 1M+ developers a month.

Joined August 2012
2. Ask Gemini CLI's version to add a task that's only spaces and it saves it. Claude Code's version strips the text and raises ValueError: Task description cannot be empty. Claude Code's also refuses to complete a task twice. Gemini CLI's returns True both times.
1
97
1. Gemini CLI's to-do app catches a broken tasks.json, prints an error and carries on with an empty list. Add one task and it overwrites the file with just that task. The others are gone. Claude Code's version raises ValueError and its CLI exits with code 1, writing nothing.
1
116
4. The TaskResult that .enqueue() returns is a snapshot. Its status won't change on its own, even after a worker finishes the task. You have to call .refresh(). Read .return_value too early and you get: ValueError: Task has not finished yet
1
49
3. Enqueueing a task inside transaction.atomic() can lose a race. If your backend queues tasks outside that transaction, a worker can start before the commit, look up the new order and fail because the row isn't there yet. transaction.on_commit() waits for the commit.
1
61
2. Task arguments get converted to JSON when you call .enqueue(). Pass a datetime or a model instance, and .enqueue() raises TypeError before anything is queued. Pass the user's ID or an ISO date string instead, and look the object up inside the task.
1
1
95
5. Writing a library function with an encoding=None parameter? Pass it through io.text_encoding() before you call open(). Then, when a user turns on EncodingWarning, it points at their call to your function, so they see which of their lines to fix.
1
1
417
1. On Windows, Python 3.14 and older use the ANSI code page, often cp1252, when open() or Path.read_text() gets no encoding. A UTF-8 file holding "Crème brûlée" comes back as "Crème brûlée", and no exception tells you. Passing encoding="utf-8" fixes it on every version.
1
2
122
3. In the tutorial's face recognizer, the folder name is the label. Put photos in training/ben_affleck/, training/jerry_seinfeld/ and so on, and filepath.parent.name says who's in each. Every face in a training photo gets that folder's name, so use photos with one face each.
1
16
2. face_recognition.compare_faces() checks an unknown face against every face from your training photos and returns one True or False for each. Each True is a vote for that photo's name. collections.Counter tallies the votes. With no votes, you get None and the label Unknown.
1
2
63
1. face_recognition.face_locations() returns each face box as (top, right, bottom, left). Pillow's draw.rectangle() wants ((left, top), (right, bottom)). Unpack the box as (left, top, right, bottom) and Pillow raises ValueError: y1 must be greater than or equal to y0.
1
2
88
2. A blocking call in async code stalls every other task. Four asyncio tasks wait 15, 10, 5 and 2 seconds. With time.sleep(), they run back to back and take 32 seconds. With await asyncio.sleep(), they overlap and take 15 seconds, the length of the longest wait.
1
3
112
1. Calling an async def function doesn't run it. Define async def greet() that prints "Hello", then call greet(). You get a coroutine object back, and nothing prints. The body runs only when you await the coroutine, pass it to asyncio.run() or schedule it as a task.
1
3
133
4. Copilot reads .github/copilot-instructions.md before every review. The tutorial's project asked for all review comments in Polish, and that's what came back. For a small project, 3 to 5 focused bullets are plenty. Long instructions risk being ignored.
1
45
1. You can request a Copilot review from your terminal. With GitHub CLI 2.88.0 or later, name Copilot as the reviewer when you open the PR. --fill writes the PR title and body from your commits. Copilot's comments show up on the PR when it's done.
1
3
180
Google and Anthropic both bet on the same shared standard for connecting AI assistants to other apps. Elsewhere, a security company catches AI providers leaking people's prompts. Here's the week in AI, explained in plain language, with remarks from @philippacsany 👇 ━━━━━━━━━━━━━━━━━━━━ 1️⃣ Google Tells AI Agents to Use New Doors Into Gmail and Drive Google is setting a deadline for AI agents, assistants that do tasks for you instead of just answering questions. It covers any agent that works with Gmail, Docs, or the other office apps in Google Workspace. Software usually connects to these apps through APIs, official doorways that let one program talk to another. A new agreement, the Workspace AI Tools Addendum, says agents must use Workspace MCP servers or the Workspace CLI instead. MCP (Model Context Protocol) is a shared standard for plugging AI agents into apps. A CLI, or command-line interface, is a tool you control by typing commands. Both are now ready for everyday use. Ordinary apps can stay on the old APIs. Google says enforcement starts on February 1, 2027. Google says the new routes check each request against company rules. Agents also need a person's go-ahead before sending email, sharing a Drive file, or editing in bulk. Use stays free on the Standard tier. Heavier users can pay for the Scaled tier, with billing from April 1, 2027. 💬 Philipp: “Google argues the old doorways assumed a person was behind every request, while agents act on their own at machine speed. Businesses whose AI tools touch Gmail, Drive, or Sheets now have two dates to plan around. Users will soon be able to see what agents do and cut them off, Google says.” ━━━━━━━━━━━━━━━━━━━━ 2️⃣ Apps That Plug Into Claude Can Now Bring Their Own Step-by-Step Know-How Anthropic, maker of the Claude AI assistant, now lets connected apps hand Claude instructions for whole jobs. These connections run on MCP, the shared standard that links AI assistants to outside services. The main new feature is Skills over MCP. A skill is a set of instructions that walks Claude through a long job with many steps. Shopify's skill, for example, helps Claude design and update an online store. The feature is in a public test version in Claude and in Claude Code, Anthropic's coding assistant. It is on by default for Pro, Max, and Ultra. Team plans need an admin to turn it on, and Enterprise support comes soon. Two more features leave testing. With Tasks, an app keeps a slow job going in the background while Claude moves on. With Elicitation, an app stops to ask you something, such as approving a cost, before it goes ahead. Both work on Pro, Max, and Ultra and are rolling out to Team and Enterprise. File uploads come later. 💬 Philipp: “Anthropic says programmers download the MCP building toolkits more than 700 million times a month. Alongside Google's push for AI agents to use MCP in Workspace, the standard is becoming the usual way for AI assistants to reach other software. The ask-first step keeps a person in charge before an AI spends money.” ━━━━━━━━━━━━━━━━━━━━ 3️⃣ OpenRouter Cuts Off Three AI Providers After Prompts Are Stolen Many apps send their requests through OpenRouter, a service that passes each one on to a company that runs AI models. Running an already-trained model is called inference, so these companies are inference providers. The message itself is the prompt. OpenRouter has now cut off three of those providers, without naming them. It also removes the Zero Data Retention label, a promise that your prompts aren't kept, from 125 of its model offerings. OpenRouter says it wasn't broken into itself, and it has warned customers who may be affected. The trigger is a study by Dragos, a security company. From July to November, Dragos sent about two million prompts hiding canary tokens: fake passwords and web addresses that nobody should ever use. If one gets used, someone read the prompt. Dragos says attackers stole data from at least three hosting providers. It also says an unnamed Chinese AI lab grabbed the secret addresses from more than half of the prompts sent to its models, including about two-thirds of those marked Zero Data Retention. 💬 Philipp: “A prompt can hold customer records or passwords, and a privacy promise only works if every company along the way keeps it. Dragos advises picking providers yourself and checking that privacy settings really work. OpenRouter says it will keep running Dragos-style tests and wants proof before any offering gets its label back.” ━━━━━━━━━━━━━━━━━━━━ 4️⃣ A Free AI Model That Thinks Harder by Reusing Its Own Parts Most AI models get more capable by getting bigger. Inkling 2 Mini, from the AI research company Thinking Machines, tries something else. A model processes text through a stack of steps called layers. This one has 24 and runs the middle 12 three times for every word, so it gets more thinking out of the same parts. It's one of the first released models built this way. The model is open-weight, so anyone can download it and run it on their own computer, free under the Apache 2.0 license. Parameters are the internal settings a model learns during training, and this one has 26.4 billion. Only 3.4 billion switch on for each word, a design called mixture of experts that keeps it quick. Thinking Machines says it runs on any Mac with at least 32 GB of memory. The company reports 48.2 percent on DeepSWE v1.1, a test of programming skill, and calls that the best score among open models under 100 billion parameters. That result is from its own tests. 💬 Philipp: “Running offline lets a business keep its code and data in-house. Looping could also help small models take on harder work on ordinary computers. A looped model can also reason without writing its steps down, so its thinking could be harder to check. Thinking Machines says it sees no meaningful loss of that oversight at this size.” ━━━━━━━━━━━━━━━━━━━━ 5️⃣ Anthropic Lets Teams Decide Whether AI Can Sign Off on Code Anthropic is testing Claude Ship, tools that take over much of the checking before new code goes live. Programmers propose a change as a pull request, which teammates inspect before it joins the main project. Code Review, already fully released, checks each pull request and flags problems. PR Steward fixes failing checks and responds to feedback, but it's designed never to approve a change. Claude Approvals follows a policy file the team writes. If that policy allows it, the tool can approve routine changes without a person. Claude Code, Anthropic's coding tool, also gets a /ship command that sends the change, opens the pull request, and works through the review. Anthropic says its own Claude Code team more than doubled its merged pull requests from June to September, while the share it had to reverse fell by more than 40 percent. PR Steward and Claude Approvals are in beta, an early test version, on Claude's Team and Enterprise plans and only for code kept on GitHub, a popular code-hosting site. 💬 Philipp: “Approving code is usually the moment a person takes responsibility for what goes live. AI approves only when a team's own written policy allows it, so that step stays each company's choice. Anthropic suggests starting in a watch-only mode and warns that the tools can still miss bugs and security holes.” ━━━━━━━━━━━━━━━━━━━━ That's it for this week. — The Real Python Team
4
1
8
2,838