Simple Python Editor Online
txt = "hello, and welcome to my world." x = txt.capitalize() print (x)
About This Python Editor
Python's defining feature is that indentation is syntax: a block is defined by how far it is indented, not by braces. That is why a Python editor has to understand indentation properly, and why mixing tabs and spaces is a syntax error rather than a style complaint.
The editor keeps indentation consistent as you type and highlights strings, decorators and comprehensions. It edits code and does not execute it.
Python syntax reference
| Syntax | What it does |
|---|---|
f"{name} scored {score:.1f}" |
f-string with formatting. The fastest and clearest way to build strings since 3.6. |
[x * 2 for x in items if x > 0] |
List comprehension. Swap the brackets for {} to build a set or dict. |
def f(a: int, b: str = "x") -> bool: |
Type hints. Not enforced at runtime, but read by mypy, IDEs and pydantic. |
with open(path) as fh: |
Context manager - closes the file even if the block raises. |
match value:\n case {"type": "a", **rest}: |
Structural pattern matching, added in 3.10. Far more than a switch. |
a, *rest = items |
Extended unpacking. |
from dataclasses import dataclass |
Generates __init__, __repr__ and __eq__ from annotated fields. |
async def f(): await g() |
Coroutines, driven by asyncio. |
Traps that bite everyone once
- Mutable default arguments.
def f(items=[])creates the list once, at definition, and every call shares it. UseNoneas the default and build the list inside. - Late binding in closures. Functions created in a loop capture the variable, not its value at the time. Bind it with a default argument:
lambda x, i=i: .... - is versus ==.
istests identity,==tests equality. Small integers and short strings are interned, soisappears to work and then stops working on larger values. - Copying. Assignment binds a name, it does not copy.
copy.deepcopy()is what you want for nested structures. - The GIL. Threads do not give you CPU parallelism in CPython. Use
multiprocessingfor CPU-bound work and threads or asyncio for I/O-bound work.
Your Code Never Leaves Your Browser
The editor is JavaScript running in this tab. Nothing you type is posted to a server, stored, logged or associated with you, and there is no account and no autosave. That makes it safe to paste a snippet from a private codebase in order to read it with highlighting. The trade-off is that nothing persists either — refresh the page and your content is gone, so copy anything you want to keep.
Frequently Asked Questions
Can I run Python in this editor?
No. Python needs an interpreter, and none is attached to this page - nothing you type is executed or uploaded. Use a local install or a notebook environment to run code.
Tabs or spaces?
Four spaces, per PEP 8, and never mixed with tabs in the same file - Python 3 raises a TabError for inconsistent indentation rather than guessing.
What is the difference between a list and a tuple?
A list is mutable and a tuple is not. That makes tuples hashable, so they can be dictionary keys and set members, and it makes them a good signal that a sequence is a fixed record rather than a growing collection.
Editors for Other Languages
Same editor, configured for a different language, each with its own syntax reference.