From PHP to Python
You're almost a Python developer. You just don't know it yet.
What you write today…
$names = ['Inès', 'Ada', 'Sam', 'Mike'];
// ['INÈS', 'MIKE']
array_values(array_map(
fn($name) => mb_strtoupper($name),
array_filter(
$names,
fn($name) => mb_strlen($name) > 3
)
));
…what you'll write soon
names = ['Inès', 'Ada', 'Sam', 'Mike']
# ['INÈS', 'MIKE']
[name.upper() for name in names if len(name) > 3]
What you get
I had the honor of reading a draft of this book. It's been extremely helpful. Most Python books and courses start with the basics of programming; this book assumes you have experience with PHP so you can dive into the relevant differences really quickly. Recommended!
Not ready yet?
Start with 7 free chapters. No account or credit card required.
Learn Python the smart way
Start from what you know
Take your existing PHP knowledge and map it directly to Python. You learned so many things over the years (variables, loops, functions, objects, etc.). Why not reuse that knowledge?
My promise to you: this course is the fastest way to learn Python you'll find, if you already know PHP.
Side-by-side code
Whenever relevant, PHP and Python code are shown side by side so you can understand the differences at a glance.
Both languages are displayed in separate, syntax-highlighted code blocks (you can even choose your favorite color theme for each!).
Stop wasting time
You hate wasting your time? I hate wasting yours too.
I keep things concise: I avoid unnecessary sentences and filler. Every paragraph, every example is there for a reason.
Concise doesn't mean shallow: we go very deep into many topics.
It is brilliant. I think you've done a stellar job. No criticisms.
Python features
What makes Python truly powerful is its versatility across domains. Learn Python once, apply it everywhere.
Scripting & CLI
Automate system administration tasks, DevOps workflows, and batch processing. Python's simplicity makes it perfect for writing maintainable automation scripts.
Huge Ecosystem
Access PyPI's millions of packages for any use case.
Data Science & AI
After finishing this course, you could explore machine learning with NumPy, pandas, and scikit-learn. Python's language foundation transfers perfectly to data science.
Python has a different philosophy that brings interesting solutions to common problems. Explore some features that make Python unique.
Context Managers
Context managers provide a clean and efficient way to do always ensure that some actions will be done even if an error occurs. This is very useful to manage resources like file handling, database connections, and network sockets.
with open('example.txt', 'r') as file:
data = file.read()
# The file is automatically closed after the `with` block
Operator overloading
Python allows you to define custom behavior for standard operators (like +, -, *, etc.) in your classes. This feature, known as operator overloading, can be very useful to build and use Value Objects.
class Money:
def __init__(self, amount):
self.amount = amount
def __add__(self, other):
return Money(self.amount + other.amount)
# Usage
m1 = Money(100)
m2 = Money(50)
# Money(150)
m3 = m1 + m2 # Uses the overloaded + operator
Comprehensions
Python's comprehensions are an elegant concise way to create lists, sets, and dictionaries, replacing our good old array_map and array_filter.
numbers = range(1, 11)
# Create list of squares
squares = [x**2 for x in numbers]
# Filter and transform
even_squares = [x**2 for x in numbers if x % 2 == 0]
# Create a dict
squares_dict = {x: x**2 for x in numbers}
Slicing
Any sequence (list, tuple or string) can be sliced with a compact syntax.
letters = ['a', 'b', 'c', 'd', 'e', 'f']
# 'f': the last item, no length needed
letters[-1]
# ['b', 'c', 'd']: from index 1, up to (excluding) 4
letters[1:4]
# ['a', 'b', 'c', 'd']: everything but the last two
letters[:-2]
# ['a', 'c', 'e']: every second item
letters[::2]
# 'nohtyP': a negative step reverses the sequence
'Python'[::-1]
Decorators
Decorators allow you to modify the behavior of functions or classes in an elegant way. They are a powerful way to implement concerns like logging, access control, or caching.
import time
def timer(func):
def wrapper(*args, **kwargs):
start = time.perf_counter()
result = func(*args, **kwargs)
elapsed = time.perf_counter() - start
print(f"{func.__name__} took {elapsed * 1000:.2f} ms")
return result
return wrapper
@timer
def count_words(filename):
with open(filename) as file:
return len(file.read().split())
# prints "count_words took 42.75 ms"
count_words('book.txt')
Python is the new black
I have 15 years of experience in PHP dev and needed to learn Python for a hiring test, this book was really made for people like me.
Python has become one of the most valued skills in the job market. Whether you want to boost your career, gain higher salaries, or stay competitive in a rapidly evolving tech landscape, Python is the skill that opens doors.
All the data points below consistently highlight Python's immense popularity and growth in the developer community.
language on GitHub, growing 48% year over year
GitHub Octoverse 2025
GitHub's 2025 Octoverse
GitHub's 2025 Octoverse survey reveals Python ranks #2 among all programming languages, with 2.6 million active contributors and a remarkable 48% year-over-year growth rate.
Python remains dominant in AI and data science, establishing itself as the essential language for exploratory AI work through widespread Jupyter notebook adoption.
most used language by professional developers
Stack Overflow 2025
Stack Overflow Survey 2025
The Stack Overflow Survey shows the languages developers use most frequently. Python ranks 4th among professional developers, right after JavaScript, HTML/CSS, and SQL.
Python adoption grew in 2025: After more than a decade of steady growth, Python's adoption has accelerated significantly. It saw a 7 percentage point increase from 2024 to 2025; this speaks to its ability to be the go-to language for AI, data science, and back-end development.
Stack Overflow Survey 2025 - Most Popular Technologies (Languages)
| Rank | Language | Usage |
|---|---|---|
| 1 | JavaScript | 66% |
| 2 | HTML/CSS | 61.9% |
| 3 | SQL | 58.6% |
| 4 | Python | 57.9% |
| 5 | Bash/Shell | 48.7% |
| 6 | TypeScript | 43.6% |
| 7 | Java | 29.4% |
| 8 | C# | 27.8% |
| 9 | C++ | 23.5% |
| 10 | PowerShell | 23.2% |
| 11 | C | 22% |
| 12 | PHP | 18.9% |
language PHP developers want to switch to
JetBrains State of PHP 2025
JetBrains: The State of PHP 2025
According to JetBrains’ State of PHP 2025 survey, Python is the second most desired language for developers looking to switch next year, right behind Go.
More than 10% of PHP developers said they’re interested in learning Python.
Are you one of them?
Do you plan to adopt or migrate to other languages in the next 12 months? If so, which ones?
| Language / Option | Percentage |
|---|---|
| No, I'm not planning to adopt or migrate | 58% |
| Go | 15% |
| Python | 11% |
| Rust | 7% |
| TypeScript | 7% |
| Kotlin | 6% |
Table of Contents
7 of the 58 chapters are free, including Decorators and Testing with unittest.
Introduction
Before we start
Language syntax
Data types
Positional and keyword arguments
Unpacking
Comprehensions
Local and global variables
Classes and objects
Objects, objects… objects everywhere!
== and is explained
Imports, modules and packages
PEP ?
Exceptions
Working with strings
Datetimes
Match case
Working with regexes
Magic methods
Lambdas
Documenting and debugging your code
Decorators
Context managers
Generators
Managing dependencies with pip
Let's bring some light with uv
Managing multiple Python versions with uv
Monkey patching
Testing with unittest
Testing with pytest
Type hints
Enums
Interacting with the filesystem
Working with environment variables
Logging
Template-strings
Interacting with the CLI
Walrus operator
DTOs in Python
Mixins
Interfaces
Serializing
Standard lib and interesting modules
Tooling and linting
The long-running shift
HTTP Clients
Interacting with databases
SQLAlchemy
Publishing a package on PyPI
Concurrency: Theory and Processor
Concurrency: Threading
Concurrency: Multiprocessing
Concurrency: AsyncIO
Async in practice
Web frameworks
WSGI and servers
Python culture
Lexicon
The book is amazing - it simply fit in with my needs perfectly. I've been doing PHP for 25 years, as well as Javascript, Typescript, Kotlin. I wanted to get a feel for Python and reading your book has made the entire process super comfortable. It is so well written, but the real gold is how you've made the right assumptions about what an experienced PHP dev will already know. The balance is very well calculated.
The Author
Yann Rabiller
Backend developer
I’m a professional backend developer and author, and I live in Paris, France. I have over 10 years of
experience building
robust, scalable web applications and worked extensively with Symfony, Laravel, and Django.
I'm always happy to discover new technologies and approaches, and I love teaching what I know. I'm
absolutely convinced
you can learn anything quickly and efficiently as soon as you have the right teacher.
Frequently Asked Questions
You've read this far.
Time to write some Python.
Start with the 7 free chapters. No signup, no credit card. When you're convinced, unlock all the chapters once and for all.
Start reading