Python's splitlines() Method Handles More Line Boundaries Than Just Newlines
By
Bogdanp
Crisped on the outside, thoughtful enough on the inside.
Summary
The article reveals that Python's str.splitlines() method splits strings on more line boundaries than just the common newline characters (\n, \r, \r\n). It actually handles a superset of universal newlines including line tabulation (\v), form feed (\f), file separator (\x1c), group separator (\x1d), and record separator (\x1e). The author shares this discovery after being surprised by the method's broader functionality beyond what they initially assumed.
Key quotes
· 3 pulledThis method splits on the following line boundaries. In particular, the boundaries are a superset of universal newlines.
I always assumed that Python's str.splitlines() split strings by 'universal newlines', i.e., \n, \r, and \r\n. But it turns out it does a lot more than that.
The boundaries are a superset of universal newlines.
You might also wanna read
Python 3.15 JIT Compiler Achieves Performance Goals Ahead of Schedule
The article reports that Python 3.15's JIT compiler development is back on track and has achieved its performance goals ahead of schedule. T
Rethinking Design Patterns in Python: Why Some Are Unnecessary
The article critiques the overuse of traditional design patterns in Python, arguing that many of these patterns, originally designed for lan
Why Average LLM Use Is Likely Destroying Value in Software Development
The author argues that, contrary to prevailing hype, the average use of Large Language Models (LLMs) is likely destroying value rather than
How AI Accelerated Prototyping: From Idea to Tangible in Record Time
The author reflects on how AI has transformed their prototyping workflow. Previously, the biggest bottleneck was the time needed to scaffold
GitLab 19.0 launches with Secrets Manager, agentic workflows, and self-hosted AI models
GitLab 19.0 has been released, positioning itself as an intelligent orchestration platform for DevSecOps. The release includes expanded secr
bit.ly·17h agoCentralizing Error Handling in Rust with Custom AppError Enums
This article discusses the importance of centralizing error handling in Rust applications using a custom AppError enum combined with map_err
