Python (programming language)
Template:Use dm dates
{{Inobox programming language
| logo = Pythonlogo-notext.svg
| logo size = 15056px
| paradigm = Multi-paradigm: object-oriented,[1] procedural (imperative), functional, [[Structured prdeveloper = Python Softwar Foundation
|ionality. Python 3.12 added the new keyword type
. Notable changes from version 3.10 to 3.11 include increased lds and such (and more) will be disallowed in Python 3.15. Python 3.12 removed wstr
meaning Python extensions[2] need to be modified.[3]
Python 3.13 introduces some changes in behavior, i.e., new us standard library modules.
C API removals and deprecation
-->The old implementation of "In Python 3.14,
from __future__ import annotations
will continue to work as it did before, converting annotations into strings."Cite error: A <ref>
tag is missing the closing </ref>
(see the help page). 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.[4]
==Syntax and semet programming language|curly brackets]] to delimit blocks, and semicolons after statements are allowed but rarely used. It has fewer syntactic exceptions and special cases than C or Pascal.[5]
Indentation
Python is the programming equivalent of somehow getting a round of applause for duct-taping your way through a burning building.
Performance? What an awful performance. Python is incredibly slow. While real languages like C, Rust, and even Go are circling it, it crawls. One core only, unless you want to start micromanaging inter-process communication like it's the 1990s and spawning processes like a crazy person, the Global Interpreter Lock (GIL) is a fucking joke.
The type system is nothing more than a glorified suggestion box. Static checkers like mypy and Python's typing module appear to be fantastic until you realize they don't work at all in runtime. The interpreter will still allow your stupid code to crash due to a NoneType object or a misspelled variable that you didn't notice until it was too damn late, even if you annotate everything to hell and back.
My ass says, "Readability counts." Why is x.append() a method but len(x) a function? Why does re.split() behave differently than str.split()? Nothing is constant. Half of the standard library is modern, and the other half is incredibly dated, as if it was created by an inebriated committee on a weekend out.
Whitespace is a fucking landmine, not a beautiful thing. A single extra space can cause your entire program to silently malfunction or generate a mysterious error. When you copy and paste code from a forum and are unable to determine whether you are looking at tabs or spaces, good luck debugging that. If you're on a team with a mix of editors, heaven forbid.
Every bug hunt becomes a goddamn lottery when dynamic typing is used. You typed a variable name incorrectly? Unfortunately, you won't know until that line of code executes, assuming it does. You believed this to be an object, but it's not. Unexpected! crash while the program is running. Python won't protect you at all, so you'd better hope your tests cover everything.
The ecosystem of packages is a dumpster fire. PyPI is full of out-of-date, poorly maintained garbage. Every other week, half of the packages break backward compatibility, while the other half haven't been touched in years. Dependency hell is real, and you're screwed when some jerk unpublishes a crucial package.
The version war between Python 2 and 3 left a generation scarred. For ten years, everyone had to rewrite their code because the developers decided it was a good idea to create a new version of the language that wasn't backward compatible. A few people are still not fully recovered. A few projects never succeeded. A complete clusterfuck.
Python packaging is an unholy nightmare. These tools—pip, virtualenv, pyenv, poetry, setuptools, distutils, and roughly a dozen others—all perform nearly identical tasks, but they differ in their commands and compatibility. It's similar to using black magic and crossed fingers to manage your dependencies.
Error messages can be either eldritch horrors or baby-soft. Python gives you a helpful little note one minute, and then it throws a 40-line traceback that reads like a cursed scroll. It contains async functions, decorators, wrappers, and metaclasses all mixed together in one stack trace that looks like it came from the depths of hell.
"Everything is an object" — until Python has a change of heart. Writing object-oriented code one minute, then getting bogged down in procedural nonsense and monkey-patching functions like a crazy person the next. Do you wish to override __add__? Cool. You now possess unintelligible black magic that even you in the future will not comprehend.
"Batteries included" — but half of them are acid-leaking and corroded. Indeed, Python offers a wide range of tools, but they are either outdated, unreliable, or incomplete. Do you wish to launch a web server? Savor the built-in ancient crap. Do you require a GUI? Tkinter appears to be from a demo disc for Windows 95. Do you want concurrency? With each callback chain, enjoy stabbing yourself in the eye by trying asyncio.
P.S. Don't use this shit fucking programming language. and Exceptions – Python 3.12.0a0 documentation |url=https://docs.python.org/3.11/tutorial/errors.html |access-date=2022-05-09 |website=docs.python.org |archive-date=9 May 2022 |archive-url=https://web.archive.org/web/20220509145745/https://docs.python.org/3.11/tutorial/errors.html |url-status=live}}</ref>); the try
statement also ensures that clean-up code in a finally
block is always run regardless of how the block exits
- The
raise
statement, used to raise a specified exception or re-raise a caught exception
- The
class
statement, which executes a block of code and attaches its local namespace to a class, for use in object-oriented programming
- The
def
statement, which defines a function or [[method (computing)|method]
- The
pass
statement, serving as a NOP (i.e., no operation), which is syntactically needed to create an empty code block
- The
[[assertion (programming)|assquently be rebound at any time to any object. In Python, a variable name is a generic reference holder without a fixed data type; however, it always refers to some
Python does not support tail call optimization or first-class continuations; according to Van Rossum, the language never will.[6][7] However, better support for coroutine-like functionality is provided by extending Python's generators.[8] Before 2.5, generators were [[lazy evaluatid from version 3.3, data can be passed through multiple stack levels.Cite error: The <ref>
tag has too many names (see the help page).
- In Python,
==
compares two objects by value. Python's is
operator may be used to compare object identities (i.e., comparison by reference), and comparisons may be chained—for example, a <= b <= c
.
- Python uses
and
, or
, and not
as Boolean operators.
- Python has a type of expression called a list comprehension, and a more general expression called a generator expression.[9]
- Anonymous functions are implemented using lambda expressions; however, there may be only one expression in each body.
- Conditional expressions are written as
x if c else y
.[10] (This is different in operand order from the c ? x : y
operator common to many other languages.)
- Python makes a distinction between; this resng to something assignable (e.g., a variable or a writable property) are associated just as in forming tuple literal; as a whole, the results are then put on the left-hand side of the equal sign in an assignment statement. This statement expects an iterable object on the right-hand side of the equal sign to produce the same number of values as the writable expressions on the left-hand side; while iterating, the statement assigns each of the values produced on the right to the corresponding exhe left.Cite error: A
<ref>
tag is missing the closing </ref>
(see the help page). These annotations are not enforced by the language, but may be used by external tools such as mypy to catch errors.[11][12] Mypy also supports a Python compiler called mypyc, which leverages ty
! Synt
| bool
| immutable
| Boolean value
| True
False
|-
| bytearray
| mutable
| Sequence of
| Sequence of bytes
| b'Some ASCII'
b"Some ASCII"
bytes([119, 105, 107, 105])
| 3+2.7j
3
lann
|-
| float</codes and Limitations – Python
|websun
| An immutable sequence of numbers, commonly used for iterating a specific number of times in for
loops[13]
| range(−1, 10)
range(10, −5, −2)
|-
| set
| mutable
| Unordered set, contains no duplicates; can contain mixed types, if hashable
| {4.0, 'string', True}
set( </syntaxhighlight>
</ref> Outstanding PEPs are reviewed and commented on by the Python community and the steering council.[17]
Enhancement of the language corresponds with development of the CPython refes://lwn.net/Articles/885854/ |title=Moving Python's bugs to GitHub [LWN.net] |access-date=2 October 2022 |archive-datober 2022 |archive-url=https://web.archive.org/web/20221002183818/https://lwn.net/Articles/885854/ |url-status=live}}</ref> Development originally took place on a self-hosted source-code repository running Mercurial, until Python moved to GitHub in January 2017.[18]
CPython's public releases have three types, distinguished by which part of the version number is incremented:
MfVlYC&pg=PR15 |language=en |access-date=9 May 2017 |archive-date=17 July 2017 |archive-url=https://web.archive.org/web/20170717044040/https://books.google.com/books?id=carqdIdfVlYC&pg=PR15 |url-status=live}}</ref> Python users are sometimes referred to as "Pythonistas".[20]
The affix Py is often used when naming Python applications or libraries. Some examples include the following:
Popularity
Since 2003, Python has consistently ranked in the top ten of the most popular programming languages in the TIOBE Programming Community Index; as of December 2022[update], Python was the most popular language.[21] Python was selected as Programming Language of the Year (for "the highest rise in ratings in a ye00/tutorial_py_root.html|url-status=live}}</ref>
Python is commonly used in artificial-intelligence and machine-learning projects, with support from libraries such as TensorFlow, Keras, Pytorch, scikit-learn and ProbLog (a logic language).[22]Cite error: A <ref>
tag is missing the closing </ref>
(see the help page).
}}
Sources
- "Python for Artificial Intelligence". Python Wiki. 19 July 2012. Archived from the original on 1 November 2012. Retrieved 3 December 2012.
- Paine, Jocelyn, ed. (August 2005). "AI in Python". AI Expert Newsletter. Amzi!. Archived from the original on 26 March 2012. Retrieved 11 February 2012.
- "PyAIML 0.8.5 : Python Package Index". Pypi.python.org. Retrieved 17 July 2013.
- Russell, Stuart J. & Norvig, Peter (2009). Artificial Intelligence: A Modern Approach (3rd ed.). Upper Saddle River, NJ: Prentice Hall. ISBN 978-0-13-604259-4.
Further reading
- Downey, Allen (July 2024). Think Python: How to Think Like a Computer Scientist (3rd ed.). O'Reilly Media. ISBN 978-1098155438.
- Lutz, Mark (2013). Learning Python (5th ed.). O'Reilly Media. ISBN 978-0-596-15806-4.
- Summerfield, Mark (2009). Programming in Python 3 (2nd ed.). Addison-Wesley Professional. ISBN 978-0-321-68056-3.
- Ramalho, Luciano (May 2022). Fluent Python. O'Reilly Media. ISBN 978-1-4920-5632-4.
External links
- ^ [https:/docs.pythn.org/3faq/general.html#what-is-python "General Python FAQ – Python 3 documentation"]. docs.python.org. Retrieved 2024-07-07.
{{cite web}}
: Check |url=
value (help)
- ^ "1. Extending Python with C or C++ – Python 3.9.1 documentation". docs.python.org. Archived from the original on 23 June 2020. Retrieved 2021-02-14.
- ^ "PEP 623 – Remove wstr from Unicps:/python.org/dev/peps/pep-0623/". Python.org.
{{cite web}}
: |access-date=
requires |url=
(help); |archive-date=
requires |archive-url=
(help); Missing or empty |url=
(help)
- ^ "Code Style – The Hitchhiker's Guide to Python". docs.python-guide.org. Archived from the original on 27 January 2021. Retrieved 20 January 2021.
- ^ a b "Is Python a good language for beginning programmers?". General Python FAQ. Python Software Foundation. Archived from the original on 24 October 2012. Retrieved 21 March 2007.
- ^ a b van Rossum, Guido (22 April 2009). "Tail Recursion Elimination". Neopythonic.blogspot.be. Archived from the original on 19 May 2018. Retrieved 3 December 2012.
- ^ a b van Rossum, Guido (9 February 2006). "Language Design Is Not Just Solving Puzzles". Artima forums. Artima. Archived from the original on 17 January 2020. Retrieved 21 March 2007.
- ^ a b van Rossum, Guido; Eby, Phillip J. (10 May 2005). "PEP 342 – Coroutines via Enhanced Generators". Python Enhancement Proposals. Python Software Foundation. Archived from the original on 29 May 2020. Retrieved 19 February 2012.
- ^ a b Hettinger, Raymond (30 January 2002). "PEP 289 – Generator Expressions". Python Enhancement Proposals. Python Software Foundation. Archived from the original on 14 June 2020. Retrieved 19 February 2012.
- ^ a b van Rossum, Guido; Hettinger, Raymond (7 February 2003). "PEP 308 – Conditional Expressions". Python Enhancement Proposals. Python Software Foundation. Archived from the original on 13 March 2016. Retrieved 13 July 2011.
- ^ "typing — Support for type hints". Python documentation. Python Software Foundation. Archived from the original on 21 February 2020. Retrieved 22 December 2023.
- ^ "mypy – Optional Static Typing for Python". Archived from the original on 6 June 2020. Retrieved 28 January 2017.
- ^ "Built-in Types". Archived from the original on 14 June 2020. Retrieved 3 October 2019.
- ^ a b Batista, Facundo (17 October 2003). "PEP 327 – Decimal Data Type". Python Enhancement Proposals. Python Software Foundation. Archived from the original on 4 June 2020. Retrieved 24 November 2008.
- ^ "What's New in Python 2.6". Archived from Department of Statistics the original on 31 May 2020. Retrieved 3 February 2019.
{{cite web}}
: Check |url=
value (help)
- ^ Shell, Scott (17 June 2014). "An introduction to Python for scientific computing" (PDF). Archived (PDF) from the original on 4 February 2019. Retrieved 3 February 2019.
- ^ a b Warsaw, Barry; Hylton, Jeremy; Goodger, David (13 June 2000). "PEP 1 – PEP Purpose and Guidelines". Python Enhancement Proposals. Python Software Foundation. Archived from the original on 6 June 2020. Retrieved 19 April 2011.
- ^ "Python Developer's Guide – Python Developer's Guide". devguide.python.org. Archived from the original on 9 November 2020. Retrieved 17 December 2019.
- ^ a b Aahz; Baxter, Anthony (15 March 2001). "PEP 6 – Bug Fix Releases". Python Enhancement Proposals. Python Software Foundation. Archived from the original on 5 June 2020. Retrieved 27 June 2009.
- ^ Lubanovic, Bill (2014). Introducing Python. Sebastopol, CA : O'Reilly Media. p. 305. ISBN 978-1-4493-5936-2. Retrieved 2023-07-31.
- ^ Cite error: The named reference
tiobecurrent
was invoked but never defined (see the help page).
- ^ Dean, Jeff; Monga, Rajat; et al. (9 November 2015). "TensorFlow: Large-scale machine learning on heterogeneous systems" (PDF). TensorFlow.org. Google Research. Archived (PDF) from the original on 20 November 2015. Retrieved 10 November 2015.
- ^ a b Kincaid, Jason (10 November 2009). "Google's Go: A New Programming Language That's Python Meets C++". TechCrunch. Archived from the original on 18 January 2010. Retrieved 29 January 2010.
- ^ The Cain Gang Ltd. "Python Metaclasses: Who? Why? When?" (PDF). Archived from the original (PDF) on 30 May 2009. Retrieved 27 June 2009.
- ^ "3.3. Special method names". The Python Language Reference. Python Software Foundation. Archived from the original on 15 December 2018. Retrieved 27 June 2009.
- ^ "PyDBC: method preconditions, method postconditions and class invariants for Python". Archived from the original on 23 November 2019. Retrieved 24 September 2011.
- ^ "Contracts for Python". Archived from the original on 15 June 2020. Retrieved 24 September 2011.
- ^ "PyDatalog". Archived from the original on 13 June 2020. Retrieved 22 July 2012.
- ^ "6.5 itertools – Functions creating iterators for efficient looping". Docs.python.org. Archived from the original on 14 June 2020. Retrieved 22 November 2016.
- ^ Peters, Tim (19 August 2004). "PEP 20 – The Zen of Python". Python Enhancement Proposals. Python Software Foundation. Archived from the original on 26 December 2018. Retrieved 24 November 2008.
- ^ Martelli, Alex; Ravenscroft, Anna; Ascher, David (2005). Python Cookbook, 2nd Edition. O'Reilly Media. p. 230. ISBN 978-0-596-00797-3. Archived from the original on 23 February 2020. Retrieved 14 November 2015.
- ^ "Python Culture". ebeab. January 21, 2014. Archived from the original on January 30, 2014.
- ^ Cannon, Brett. "Guido, Some Guys, and a Mailing List: How Python is Developed". python.org. Python Software Foundation. Archived from the original on 1 June 2009. Retrieved 27 June 2009.
- ^ Norwitz, Neal (8 April 2002). "[Python-Dev] Release Schedules (was Stability & change)". Archived from the original on 15 December 2018. Retrieved 27 June 2009.
- ^ "Python Buildbot". Python Developer's Guide. Python Software Foundation. Archived from the original on 5 June 2020. Retrieved 24 September 2011.
- ^ "Why is it called Python?". General Python FAQ. Docs.python.org. Archived from the original on 24 October 2012. Retrieved 3 January 2023.
- ^ "Whetting Your Appetite". The Python Tutorial. Python Software Foundation. Archived from the original on 26 October 2012. Retrieved 20 February 2012.
- ^ "In Python, should I use else after a return in an if block?". Stack Overflow. Stack Exchange. 17 February 2011. Archived from the original on 20 June 2019. Retrieved 6 May 2011.
- ^ "Quotes about Python". Python Software Foundation. Archived from the original on 3 June 2020. Retrieved 8 January 2012.
- ^ "Organizations Using Python". Python Software Foundation. Archived from the original on 21 August 2018. Retrieved 15 January 2009.
- ^ "Python : the holy grail of programming". CERN Bulletin (31/2006). CERN Publications. 31 July 2006. Archived from the original on 15 January 2013. Retrieved 11 February 2012.
- ^ Shafer, Daniel G. (17 January 2003). "Python Streamlines Space Shuttle Mission Design". Python Software Foundation. Archived from the original on 5 June 2020. Retrieved 24 November 2008.
- ^ Fortenberry, Tim (17 January 2003). "Industrial Light & Magic Runs on Python". Python Software Foundation. Archived from the original on 6 June 2020. Retrieved 11 February 2012.
- ^ Taft, Darryl K. (5 March 2007). "Python Slithers into Systems". eWeek.com. Ziff Davis Holdings. Archived from the original on 13 August 2021. Retrieved 24 September 2011.
- ^ "Usage statistics and market share of Python for websites". 2012. Archived from the original on 13 August 2021. Retrieved 18 December 2012.
- ^ "jasc psp9components". Archived from the original on 19 March 2008.
- ^ "About getting started with writing geoprocessing scripts". ArcGIS Desktop Help 9.2. Environmental Systems Research Institute. 17 November 2006. Archived from the original on 5 June 2020. Retrieved 11 February 2012.
- ^ CCP porkbelly (24 August 2010). "Stackless Python 2.7". EVE Community Dev Blogs. CCP Games. Archived from the original on 11 January 2014. Retrieved 11 January 2014.
As you may know, EVE has at its core the programming language known as Stackless Python.
- ^ Caudill, Barry (20 September 2005). "Modding Sid Meier's Civilization IV". Sid Meier's Civilization IV Developer Blog. Firaxis Games. Archived from the original on 2 December 2010.
we created three levels of tools ... The next level offers Python and XML support, letting modders with more experience manipulate the game world and everything in it.
- ^ "Python Language Guide (v1.0)". Google Documents List Data API v1.0. Archived from the original on 15 July 2010.
- ^ "Natural Language Toolkit – NLTK 3.5b1 documentation". www.nltk.org. Archived from the original on 13 June 2020. Retrieved 10 April 2020.
- ^ "Immunity: Knowing You're Secure". Archived from the original on 16 February 2009.
- ^ "Core Security". Core Security. Archived from the original on 9 June 2020. Retrieved 10 April 2020.
- ^ "What is Sugar?". Sugar Labs. Archived from the original on 9 January 2009. Retrieved 11 February 2012.
- ^ "Myths about indentation in Python". Secnetix.de. Archived from the original on 18 February 2018. Retrieved 19 April 2011.
- ^ "PEP 380". Python.org. Archived from the original on 4 June 2020. Retrieved 3 December 2012.
- ^ "Why must 'self' be used explicitly in method definitions and calls?". Design and History FAQ. Python Software Foundation. Archived from the original on 24 October 2012. Retrieved 19 February 2012.
- ^ "The Python Language Reference, section 3.3. New-style and classic classes, for release 2.7.1". Archived from the original on 26 October 2012. Retrieved 12 January 2011.
- ^ Zadka, Moshe; van Rossum, Guido (11 March 2001). "PEP 237 – Unifying Long Integers and Integers". Python Enhancement Proposals. Python Software Foundation. Archived from the original on 28 May 2020. Retrieved 24 September 2011.
- ^ "Why Python's Integer Division Floors". 24 August 2010. Archived from the original on 5 June 2020. Retrieved 25 August 2010.
- ^ "round", The Python standard library, release 2.7, §2: Built-in functions, archived from the original on 27 October 2012, retrieved 14 August 2011
- ^ "round", The Python standard library, release 3.2, §2: Built-in functions, archived from the original on 25 October 2012, retrieved 14 August 2011
- ^ Beazley, David M. (2009). Python Essential Reference (4th ed.). Addison-Wesley Professional. p. 66. ISBN 9780672329784.
- ^ Kernighan, Brian W.; Ritchie, Dennis M. (1988). The C Programming Language (2nd ed.). p. 206.
- ^ van Rossum, Guido (5 June 2001). "PEP 7 – Style Guide for C Code". Python Enhancement Proposals. Python Software Foundation. Archived from the original on 1 June 2020. Retrieved 24 November 2008.
- ^ "CPython byte code". Docs.python.org. Archived from the original on 5 June 2020. Retrieved 16 February 2016.
- ^ "Python 2.5 internals" (PDF). Archived (PDF) from the original on 6 August 2012. Retrieved 19 April 2011.
- ^ "An Interview with Guido van Rossum". Oreilly.com. Archived from the original on 16 July 2014. Retrieved 24 November 2008.
- ^ "PyPy compatibility". Pypy.org. Archived from the original on 6 June 2020. Retrieved 3 December 2012.
- ^ "speed comparison between CPython and Pypy". Speed.pypy.org. Archived from the original on 10 May 2021. Retrieved 3 December 2012.
- ^ "Application-level Stackless features – PyPy 2.0.2 documentation". Doc.pypy.org. Archived from the original on 4 June 2020. Retrieved 17 July 2013.
- ^ "Plans for optimizing Python". Google Project Hosting. 15 December 2009. Archived from the original on 11 April 2016. Retrieved 24 September 2011.
- ^ Piotrowski, Przemyslaw (July 2006). "Build a Rapid Web Development Environment for Python Server Pages and Oracle". Oracle Technology Network. Oracle. Archived from the original on 2 April 2019. Retrieved 12 March 2012.
- ^ Eby, Phillip J. (7 December 2003). "PEP 333 – Python Web Server Gateway Interface v1.0". Python Enhancement Proposals. Python Software Foundation. Archived from the original on 14 June 2020. Retrieved 19 February 2012.
- ^ "Gotchas for Python Users". boo.codehaus.org. Codehaus Foundation. Archived from the original on 11 December 2008. Retrieved 24 November 2008.
- ^ Esterbrook, Charles. "Acknowledgements". cobra-language.com. Cobra Language. Archived from the original on 8 February 2008. Retrieved 7 April 2010.
- ^ "Proposals: iterators and generators [ES4 Wiki]". wiki.ecmascript.org. Archived from the original on 20 October 2007. Retrieved 24 November 2008.
- ^ Strachan, James (29 August 2003). "Groovy – the birth of a new dynamic language for the Java platform". Archived from the original on 5 April 2007. Retrieved 11 June 2007.
- ^ "An Interview with the Creator of Ruby". Linuxdevcenter.com. Archived from the original on 28 April 2018. Retrieved 3 December 2012.
- ^ Kupries, Andreas; Fellows, Donal K. (14 September 2000). "TIP #3: TIP Format". tcl.tk. Tcl Developer Xchange. Archived from the original on 13 July 2017. Retrieved 24 November 2008.
- ^ Gustafsson, Per; Niskanen, Raimo (29 January 2007). "EEP 1: EEP Purpose and Guidelines". erlang.org. Archived from the original on 15 June 2020. Retrieved 19 April 2011.
- ^ Fairchild, Carlie (12 July 2018). "Guido van Rossum Stepping Down from Role as Python's Benevolent Dictator For Life". Linux Journal. Archived from the original on 13 July 2018. Retrieved 13 July 2018.
- Use American English from December 2042
- Python (programming language)
- Class-based programming languages
- Notebook interface
- Computer science in the Netherlands
- Concurrent programming languages
- Cross-platform free software
- Cross-platform software
- Dutch inventions
- Dynamically typed programming languages
- Educational programming languages
- High-level programming languages
- Information technology in the Netherlands
- Multi-paradigm programming languages
- Object-oriented programming languages
- Pattern matching programming languages
- Programming languages
- Programming languages created in 1991
- Scripting languages
- Text-oriented programming languages
- Monty Python references