Polyscan
← All posts
ai-agentspythoncode-quality

What Python Is For in the Age of AI

Now that AI writes the code, Python being easy to write matters less. So why is it still everywhere? Four jobs explain it: exact computation, reaching outside systems, throwaway scripts, and letting people check the work.

One reason Python spread so widely is that it is easy to write. You can express complicated logic in a small amount of readable code. But today you can ask an AI and get working code in a few seconds, so being easy for a person to write is not the advantage it used to be.

Does that mean Python will fade? I don't think so. What changes is its role. Python has been a language people use to build software. From here on, it is also the tool an AI uses to turn what it has worked out into something that actually runs.

It helps to keep two kinds of value apart when thinking about this. One is the value of Python as a place to run programs. The other is the value of a person writing Python by hand. The second is going down, and the first is going up. This post explains why, through four jobs Python does.

Leave the arithmetic to code

Language models are good at summarizing text and deciding on an approach. They do not always give the same answer to the same question, though. Numbers used in a business need to come out the same every time, and someone needs to be able to check them afterward.

Take a quarterly sales analysis. If you hand an AI a few thousand rows of raw numbers and ask for the totals, it can misplace a digit or skip a row. So instead of having the AI do the sums, you have it write code that does the sums, and then run that code.

import pandas as pd
 
sales = pd.read_csv("sales_q3.csv")
print(sales.groupby("region")["amount"].sum())

This code returns the same totals however many times you run it. If a result looks wrong, a person can read the code and find out why. The AI's part is to read the numbers that come out and work out what they mean. Some AI assistants' data analysis features work this way behind the scenes, writing code and running it.

The AI does the thinking and the code does the computing. Python is the line between the two.

Connect the AI to the outside world

All a language model can do is take in text and give back text. It cannot query a database, change a file, or call an internal API by itself.

When an AI decides to look up a customer's order history, a program is what actually sends the query. Python is often the language for that step, the one that turns a decision into an action.

TypeScript or Go can do the same job. Python tends to get picked because the libraries for data processing and machine learning grew up around it: pandas for tables, NumPy for numerical work, PyTorch for training models. The parts are already there, so most of what an AI wants to work with is within easy reach from Python.

Write scripts that run once

Ask an AI agent to do a task and you will often see it write a small script on the spot, run it, and throw it away. Python suits this kind of use well.

For a large system that will run for years, an AI may well choose Rust or Go more often, for their strict types and speed. A script that exists only to tidy up today's data is a different case. It will never run again, so it needs neither speed nor a design that holds up over time. What matters is that it is quick to write and quick to try.

Python has no compile step. An AI can write a script, run it, read the error message, and fix it, all within seconds. And because the libraries cover so much, there is less to write. Pulling a table out of a PDF, filling in the missing values, and drawing a chart takes about a dozen lines. Less code means less time and cost to generate it, and fewer places for a mistake to get in.

Small jobs like these used to be done with shell scripts. For an AI, Python has taken over that job as a more capable command line.

Let people read and check

Even when an AI writes the code, a person is responsible for what it does. What happens with unexpected input? Could it delete a file it shouldn't? Will it cost too much to run? Someone has to check these in the end.

Python code looks close to a written description of the steps. In the sales example above, even someone who has never written Python can tell that it adds up amounts by region. A person can read what the AI is about to do and judge it before it runs. Being easy to write matters less now, but being easy to read still matters.

Reading only works while the code is short, though. A throwaway script is a dozen lines, but code that stays in a repository is another matter. Nobody can read all of a codebase that an AI changes every day. Whether a function has grown too complicated, or the same logic now lives in several places, is better measured by a tool, so that people read only the places that stand out. That is why we build pyscn, a static analysis tool for Python.

Whether people read the code directly or with a tool's help, the point is the same: code an AI wrote should not become a box nobody can see into.

What will be asked of people

It is worth looking a little further ahead. Suppose people only describe what they want in words, and an AI picks the language, writes the code, tests it, and ships it. At that point people may no longer need to touch Python at all.

What people will need then is not memorized syntax or the ability to write algorithms. I think it comes down to three things.

  1. Deciding clearly what you want. A vague request gets a vague result.
  2. Checking that the result is right. That means it fits the real-world conditions as well as running.
  3. Deciding how much to hand to the AI and who is responsible. Settle in advance what is delegated and who checks it.

All three rest on understanding the work itself more than on knowing a programming language.

Summary

In the age of AI, writing Python by hand is worth less, and Python as a tool is worth more.

Python is still a programming language for people, and it has also become the place where an AI gets things done. It computes exactly, connects to outside systems, handles one-off jobs, and lets people see what is going on. One language covering all four is why Python keeps being used now that AI writes the code.


Notes:

  • The sales code is an example written for this post.