gitmyhub

wtfpython-cn

Jupyter Notebook ★ 13k updated 1y ago

wtfpython的中文翻译/持续🚧.../ 能力有限,欢迎帮我改进翻译

A Chinese translation of the wtfpython project: a collection of surprising Python code examples with explanations of the real behavior behind each confusing result. A learning resource, not a library, nothing to install.

PythonJupyter Notebooksetup: easycomplexity 1/5

This repository is a Chinese translation of the English project called wtfpython, which collects surprising and counterintuitive Python code snippets. Each entry shows a short piece of Python code whose output looks wrong or confusing at first glance, then explains the actual Python behavior behind it. The goal is to help programmers understand how Python really works under the hood, not just how it appears to work on the surface.

The examples are grouped into several sections. One section is called "Strain your brain" and covers things like unexpected string behavior, the difference between the is and == operators, and Python's rules for how variables are shared across closures. Another section, "Slippery Slopes", covers common mistakes like modifying a list or dictionary while looping over it, or using a mutable object as a default function argument. A section called "Hidden treasures" shows lesser-known Python features that most programmers have never encountered. There is also a section on visual tricks, where code looks like it should work one way but does something different because of invisible characters or unusual Unicode.

The README itself is in Chinese, so the primary audience is Chinese-speaking Python developers. The original English version of this project, by Satwikkansal, is linked at the top. A Jupyter notebook version is also available via a web link, letting you run the code examples interactively in a browser without installing anything.

This is a learning resource and a reference, not a library or tool you install. Reading through it is useful both for beginners who want to understand Python's quirks and for experienced developers who want to double-check their assumptions about how certain edge cases behave. The full README is longer than what was shown.

Where it fits