Python 2
Python 2
Python 2
https://en.wikipedia.org/wiki/Python_(programming_language) Page 1 of 38
Python (programming language) - Wikipedia 3/25/23, 2:51 AM
https://en.wikipedia.org/wiki/Python_(programming_language) Page 2 of 38
Python (programming language) - Wikipedia 3/25/23, 2:51 AM
Python uses dynamic typing and a combination of reference counting and a cycle-detecting garbage
collector for memory management.[70] It uses dynamic name resolution (late binding), which
binds method and variable names during program execution.
Its design offers some support for functional programming in the Lisp
tradition. It has filter,mapandreduce functions; list comprehensions,
dictionaries, sets, and generator expressions.[71] The standard library has
two modules (itertools and functools) that implement functional
tools borrowed from Haskell and Standard ML.[72]
Rather than building all of its functionality into its core, Python was designed to be highly
extensible via modules. This compact modularity has made it particularly popular as a means of
adding programmable interfaces to existing applications. Van Rossum's vision of a small core
language with a large standard library and easily extensible interpreter stemmed from his
frustrations with ABC, which espoused the opposite approach.[42]
Python strives for a simpler, less-cluttered syntax and grammar while giving developers a choice in
their coding methodology. In contrast to Perl's "there is more than one way to do it" motto, Python
embraces a "there should be one—and preferably only one—obvious way to do it" philosophy.[73]
Alex Martelli, a Fellow at the Python Software Foundation and Python book author, wrote: "To
describe something as 'clever' is not considered a compliment in the Python culture."[74]
Python's developers strive to avoid premature optimization and reject patches to non-critical parts
of the CPython reference implementation that would offer marginal increases in speed at the cost
of clarity.[75] When speed is important, a Python programmer can move time-critical functions to
extension modules written in languages such as C; or use PyPy, a just-in-time compiler. Cython is
also available, which translates a Python script into C and makes direct C-level API calls into the
Python interpreter.
Python's developers aim for it to be fun to use. This is reflected in its name—a tribute to the British
comedy group Monty Python[76]—and in occasionally playful approaches to tutorials and reference
materials, such as the use of the terms "spam" and "eggs" (a reference to a Monty Python sketch) in
examples, instead of the often-used "foo" and "bar".[77][78]
https://en.wikipedia.org/wiki/Python_(programming_language) Page 3 of 38
Python (programming language) - Wikipedia 3/25/23, 2:51 AM
A common neologism in the Python community is pythonic, which has a wide range of meanings
related to program style. "Pythonic" code may use Python idioms well, be natural or show fluency
in the language, or conform with Python's minimalist philosophy and emphasis on readability.
Code that is difficult to understand or reads like a rough transcription from another programming
language is called unpythonic.[79][80]
Indentation
Python uses whitespace indentation, rather than curly brackets or keywords, to delimit blocks. An
increase in indentation comes after certain statements; a decrease in indentation signifies the end
of the current block.[82] Thus, the program's visual structure accurately represents its semantic
structure.[83] This feature is sometimes termed the off-side rule. Some other languages use
indentation this way; but in most, indentation has no semantic meaning. The recommended indent
size is four spaces.[84]
https://en.wikipedia.org/wiki/Python_(programming_language) Page 4 of 38