Python
| Designed by | Guido van Rossum |
|---|---|
| Appeared in | 1991 |
| Computational class | Turing-complete |
| Reference implementation | CPython |
| Major implementations | PyPy |
| Influenced by | anything GvR had ever heard of in 1989 |
| Influenced | uncountable |
- This article deals with Python as it relates to esoteric programming. For more general information, see the Wikipedia article on Python.
Python is C with foam padding. ~ Python community meme[1][2][3][4]
Monty Python's Flying Circus, generally known by its short name Python, is one of the most popular programming languages in the world, comparable only to ECMAScript and Excel, and is one of the few languages that non-programmers have heard of. It is a general-purpose programming language designed for readability — a design constantly tested by its users — and has found a number of uses as a glue language connecting existing packages for cryptography, database management, and numerical methods. Python can be found in niches like statistical analysis, scripting for automation, and compilation. Python's key trait is to read like pseudocode and it has effectively replaced pseudocode in many academic works; as such, it has become a common first language for new programmers.
Python was built initially by Guido van Rossum during 1990 and released to the public in 1991 as CPython, the reference implementation. It was bootstrapped to C in 2005 by the PyPy team.[5]
While languages like Forth and Lisp have been influential to esolangs predominantly because the languages are inspired by how the languages work, Python is more akin to Perl as a practical language which can implement an esolang. Esolangs based on images like StegFuck are often implemented in Python using packages like PIL/Pillow or OpenCV. Languages with arbitrary-width integers or natural numbers are also often implemented using Python's builtin int type, which is also arbitrary-width.
In terms of semantics, Python inherits from Smalltalk and Self, providing a prototype-based object-based language with a single reference-oriented calling convention.
Lambda
Python is often criticized for a weak lambda syntax. However, Python is complete for lambda-expressions! For example, habnabit 2015 implements a basic chat server in a single lambda expression.
Closure Quirk
As one of its exceptions to lexical scoping, Python has a quirky behavior for closing over scoped names. User:Corbin gave the following example in 2017:[6]
>>> l = [(lambda y: x + y) for x in range(5)] >>> [f(0) for f in l] [4, 4, 4, 4, 4]
This is known as the "lambda quirk" or "closure quirk". Relatives of Python like Monte do not have it:
▲> [for f in ([for x in (0..!5) fn y { x + y }]) f(0)]
Result: [0, 1, 2, 3, 4]
The genesis of closure quirk is likely in one of the many Lisps which inspired Python, although it is not clear which one to blame. It does not occur in Standard ML, another language whose descendants also inspired Python; for example, Corbin shows that it also does not occur in Haskell:
Prelude> [ f 0 | f <- [ (x +) | x <- [0..4] ] ] [0,1,2,3,4]
References
- ↑ J. Redford, 1993. Re: Ideas about enhancements to fileobjects. https://legacy.python.org/search/hypermail/python-1993/0490.html
- ↑ Unknown Redditor, 2007. Re: From a C programmer: which of these high level languages can I actually use? https://old.reddit.com/r/programming/comments/5ywhh/ask_reddit_from_a_c_programmer_which_of_these/c02aqal/
- ↑ M. Zadka, 2019. DevOps in Python. ISBN 978-1484244326. https://www.oreilly.com/library/view/devops-in-python/9781484244333/
- ↑ C. Simpson, 2024. Re: Coroutines and effects. https://lobste.rs/s/8gbxet/coroutines_effects#c_xs4oaz
- ↑ C. F. Bolz-Tereick, 2018. The first 15 years of PyPy: a personal retrospective. https://pypy.org/posts/2018/09/the-first-15-years-of-pypy-3412615975376972020.html
- ↑ C. Simpson, 2017. Why not Python? https://gist.github.com/MostAwesomeDude/eee722a254adc100062c1921cfa4dfc9