560 blogs tracked4,950 posts indexed

#python

50 posts · 7 companies · newest first

Curated view of this subject:Topic: Python287
1

Monte-Carlo simulations (opens on the source site)

Monte Carlo simulations (or methods) is the technique of applying randomness and the Law of large numbers to the solution of various scientific and engineering problems. One of its first documented uses was by Stanislaw Ulam and John von Neumann for nuclear weapon simulations after WWII [1]. In this post I want to provide examples of some simple uses of Monte Carlo simulations. We'll start with the classical example of calculating the value of \pi by throwing darts. Estimating pi Suppose we take a square board and inscribe a quarter of a circle into it. We then proceed to throw darts at the…

miscmathexcerpt only · body stays at the source
From the web
3

Pandas groupby with sort=False: Keep groups in order of appearance (opens on the source site)

A “groupby” call in Python Pandas is normally sorted by index. But if you’re grouping by month name, April will come before January. Pass “sort=False”, and the index will reflect […] The post Pandas groupby with sort=False: Keep groups in order of appearance appeared first on LernerPython.

pythonexcerpt only · body stays at the source
From the web
5

Building Kubernetes PR Previews with Shared Pulumi Components (opens on the source site)

My team develops a microservices application on Kubernetes, with hundreds of PRs opened each day. To let engineers test and review those changes in isolation before they’re merged, we give every pull request its own ephemeral environment. We use Pulumi to define those short-lived PR environments from a component resource that’s shared with our long-lived Dev, Stage, Prod environments. Each PR gets its own Pulumi stack and Kubernetes namespace, which we tear down once the PR is merged or closed. In this post, I’ll walk through how we’ve implemented this pattern and what we’ve learned from…

pulumikubernetesexcerpt only · body stays at the source
From the web
8

New on the LernerPython practice system: A visual debugger (opens on the source site)

I’m a big fan of exercises, which is why the LernerPython platform includes hundreds of them — all using my in-browser practice system, which handles Python, Pandas, and Git, along […] The post New on the LernerPython practice system: A visual debugger appeared first on LernerPython.

pythonexcerpt only · body stays at the source
From the web
11

Python Workers are now generally available (opens on the source site)

Python Workers allow developers to run Python web frameworks and AI orchestration libraries natively in the Cloudflare Workers runtime. You can seamlessly integrate with Cloudflare's ecosystem including D1, R2, and Workers AI without writing any JavaScript glue code.

aideveloper-platformexcerpt only · body stays at the source 27044 comments on HN (opens the discussion)
From the web
18

Python in operator: How __contains__ speeds up membership tests (opens on the source site)

How does the “in” operator work in Python? – If an object defines __contains__, then its (boolean) result is returned (coerced to bool).– If not, then Python iterates over it […] The post Python in operator: How __contains__ speeds up membership tests appeared first on LernerPython.

pythonexcerpt only · body stays at the source
From the web
19

Newsprint: Turning e-mail newsletters into a personal PDF (opens on the source site)

I really enjoy reading e-mail newsletters. They’re clever, informative, and funny, and provide me with lots of food for thought — as well as professional information that is crucial to […] The post Newsprint: Turning e-mail newsletters into a personal PDF appeared first on LernerPython.

pythonexcerpt only · body stays at the source
From the web
22

Python operator overloading: The arithmetic magic methods (opens on the source site)

Just as + in Python invokes __add__, other operators invoke other magic methods: • – is __sub__• * is __mul__• / is __truediv__• // is __floordiv__• % is __mod__• ** is __pow__ Your methods can […] The post Python operator overloading: The arithmetic magic methods appeared first on LernerPython.

pythonexcerpt only · body stays at the source
From the web
23

Claude Code always produces something. That’s the hard part. (opens on the source site)

I've been using Claude Code several hours a day for months, and I'm having a blast. But an agent does what you tell it, not what you meant — which is why validating your results now matters more than the results themselves. The post Claude Code always produces something. That’s the hard part. appeared first on LernerPython.

pythontrainingexcerpt only · body stays at the source
From the web
30

How to fix a weird pandas and pyarrow issue with BirdNetPi (opens on the source site)

Summary: If you get Python crashing immediately in BirdNetPi, try uninstalling the pyarrow Python package. I’ve got a BirdNetPi set up at home. This is a bit of software that runs on a Raspberry Pi and listens on a microphone (I’ve mounted mine on the outside of an upstairs window, using a 3D printed mount/cover […]

how-toprogrammingexcerpt only · body stays at the source
From the web
33

Some recent, and not so recent, talks and activities (opens on the source site)

There has been a long gap between posts (again!), and a lot of the stuff that I’m going to talk about in this post is fairly old too. Oh well, life keeps getting in the way of blogging. Anyway, I’ve recently submitted a talk for the FOSS4G UK 2026 conference in Leeds in October, and […]

academiccomputingexcerpt only · body stays at the source
From the web
34

PyArrow dtypes in Pandas aren’t always faster than NumPy (opens on the source site)

Using PyArrow dtypes in Python Pandas isn’t always faster: %timeit s_pyarr.mean() # 21.5ms%timeit s_np.mean() # 47.3ms %timeit s_pyarr.nlargest(10) # 667ms%timeit s_np.nlargest(10) # 663ms The post PyArrow dtypes in Pandas aren’t always faster than NumPy appeared first on LernerPython.

pythonexcerpt only · body stays at the source
From the web
35

Browser automation with Pydantic AI + Playwright (opens on the source site)

When we build agents, we often want to give them the ability to browse the web: open webpages, navigate from one page to the other, and read the content of a webpage. By combining Pydantic AI with the Playwright capability from Pydantic AI Harness, we can build agents that browse the web safely and programmatically. Using Pydantic AI with Microsoft Foundry models Pydantic AI is an open-source model-agnostic framework from Pydantic for building LLM-based applications and agents. It's type-safe and supports OpenTelemetry, making it a great choice for robust production applications. We can use…

aipythonexcerpt only · body stays at the source
From the web
36

PyArrow strings in pandas: Faster and smaller than object dtype (opens on the source site)

PyArrow strings in Python Pandas are smaller than Python strings. But they’re also far faster: %timeit s_pyarr.str.len() # 106 µs%timeit s_py.str.len() # 1.6 ms In many examples, PyArrow was far […] The post PyArrow strings in pandas: Faster and smaller than object dtype appeared first on LernerPython.

pythonexcerpt only · body stays at the source
From the web
37

PyArrow dtypes in pandas: Reading CSVs with dtype_backend (opens on the source site)

Want PyArrow dtypes in your Python Pandas data frame? The dtypes are double[pyarrow], int64[pyarrow], and string[pyarrow], not the normal NumPy ones. Note: This is still experimental… but it’s also the […] The post PyArrow dtypes in pandas: Reading CSVs with dtype_backend appeared first on LernerPython.

pythonexcerpt only · body stays at the source
From the web
39

Building safe MCP servers for your PostgreSQL database (opens on the source site)

Model Context Protocol (MCP) is an open protocol that describes how agents can connect to external tools and data sources, and is now widely supported by the most popular coding agents (like GitHub Copilot, Claude Code, and Codex) and agent frameworks (like LangChain and Pydantic AI). If you want to give agents a standard way to access the data in a database, you can build your own MCP server and expose tools for the agent to query or even modify data. But you need to design your MCP server carefully, to ensure that agents can do everything that users want - but nothing that you don't want…

mcppythonexcerpt only · body stays at the source
From the web
50 shown

Privacy choices

Reading never requires analytics. These choices last 90 days on this browser.

Essential sign-in and security storage always stays on. Read the privacy notice.