1:tocdepth: 2 2 3================== 4General Python FAQ 5================== 6 7.. only:: html 8 9 .. contents:: 10 11 12General Information 13=================== 14 15What is Python? 16--------------- 17 18Python is an interpreted, interactive, object-oriented programming language. It 19incorporates modules, exceptions, dynamic typing, very high level dynamic data 20types, and classes. It supports multiple programming paradigms beyond 21object-oriented programming, such as procedural and functional programming. 22Python combines remarkable power with very clear syntax. It has interfaces to 23many system calls and libraries, as well as to various window systems, and is 24extensible in C or C++. It is also usable as an extension language for 25applications that need a programmable interface. Finally, Python is portable: 26it runs on many Unix variants including Linux and macOS, and on Windows. 27 28To find out more, start with :ref:`tutorial-index`. The `Beginner's Guide to 29Python <https://wiki.python.org/moin/BeginnersGuide>`_ links to other 30introductory tutorials and resources for learning Python. 31 32 33What is the Python Software Foundation? 34--------------------------------------- 35 36The Python Software Foundation is an independent non-profit organization that 37holds the copyright on Python versions 2.1 and newer. The PSF's mission is to 38advance open source technology related to the Python programming language and to 39publicize the use of Python. The PSF's home page is at 40https://www.python.org/psf/. 41 42Donations to the PSF are tax-exempt in the US. If you use Python and find it 43helpful, please contribute via `the PSF donation page 44<https://www.python.org/psf/donations/>`_. 45 46 47Are there copyright restrictions on the use of Python? 48------------------------------------------------------ 49 50You can do anything you want with the source, as long as you leave the 51copyrights in and display those copyrights in any documentation about Python 52that you produce. If you honor the copyright rules, it's OK to use Python for 53commercial use, to sell copies of Python in source or binary form (modified or 54unmodified), or to sell products that incorporate Python in some form. We would 55still like to know about all commercial use of Python, of course. 56 57See `the license page <https://docs.python.org/3/license.html>`_ to find further 58explanations and the full text of the PSF License. 59 60The Python logo is trademarked, and in certain cases permission is required to 61use it. Consult `the Trademark Usage Policy 62<https://www.python.org/psf/trademarks/>`__ for more information. 63 64 65Why was Python created in the first place? 66------------------------------------------ 67 68Here's a *very* brief summary of what started it all, written by Guido van 69Rossum: 70 71 I had extensive experience with implementing an interpreted language in the 72 ABC group at CWI, and from working with this group I had learned a lot about 73 language design. This is the origin of many Python features, including the 74 use of indentation for statement grouping and the inclusion of 75 very-high-level data types (although the details are all different in 76 Python). 77 78 I had a number of gripes about the ABC language, but also liked many of its 79 features. It was impossible to extend the ABC language (or its 80 implementation) to remedy my complaints -- in fact its lack of extensibility 81 was one of its biggest problems. I had some experience with using Modula-2+ 82 and talked with the designers of Modula-3 and read the Modula-3 report. 83 Modula-3 is the origin of the syntax and semantics used for exceptions, and 84 some other Python features. 85 86 I was working in the Amoeba distributed operating system group at CWI. We 87 needed a better way to do system administration than by writing either C 88 programs or Bourne shell scripts, since Amoeba had its own system call 89 interface which wasn't easily accessible from the Bourne shell. My 90 experience with error handling in Amoeba made me acutely aware of the 91 importance of exceptions as a programming language feature. 92 93 It occurred to me that a scripting language with a syntax like ABC but with 94 access to the Amoeba system calls would fill the need. I realized that it 95 would be foolish to write an Amoeba-specific language, so I decided that I 96 needed a language that was generally extensible. 97 98 During the 1989 Christmas holidays, I had a lot of time on my hand, so I 99 decided to give it a try. During the next year, while still mostly working 100 on it in my own time, Python was used in the Amoeba project with increasing 101 success, and the feedback from colleagues made me add many early 102 improvements. 103 104 In February 1991, after just over a year of development, I decided to post to 105 USENET. The rest is in the ``Misc/HISTORY`` file. 106 107 108What is Python good for? 109------------------------ 110 111Python is a high-level general-purpose programming language that can be applied 112to many different classes of problems. 113 114The language comes with a large standard library that covers areas such as 115string processing (regular expressions, Unicode, calculating differences between 116files), internet protocols (HTTP, FTP, SMTP, XML-RPC, POP, IMAP), 117software engineering (unit testing, logging, profiling, parsing 118Python code), and operating system interfaces (system calls, filesystems, TCP/IP 119sockets). Look at the table of contents for :ref:`library-index` to get an idea 120of what's available. A wide variety of third-party extensions are also 121available. Consult `the Python Package Index <https://pypi.org>`_ to 122find packages of interest to you. 123 124 125.. _faq-version-numbering-scheme: 126 127How does the Python version numbering scheme work? 128-------------------------------------------------- 129 130Python versions are numbered "A.B.C" or "A.B": 131 132* *A* is the major version number -- it is only incremented for really major 133 changes in the language. 134* *B* is the minor version number -- it is incremented for less earth-shattering 135 changes. 136* *C* is the micro version number -- it is incremented for each bugfix release. 137 138Not all releases are bugfix releases. In the run-up to a new feature release, a 139series of development releases are made, denoted as alpha, beta, or release 140candidate. Alphas are early releases in which interfaces aren't yet finalized; 141it's not unexpected to see an interface change between two alpha releases. 142Betas are more stable, preserving existing interfaces but possibly adding new 143modules, and release candidates are frozen, making no changes except as needed 144to fix critical bugs. 145 146Alpha, beta and release candidate versions have an additional suffix: 147 148* The suffix for an alpha version is "aN" for some small number *N*. 149* The suffix for a beta version is "bN" for some small number *N*. 150* The suffix for a release candidate version is "rcN" for some small number *N*. 151 152In other words, all versions labeled *2.0aN* precede the versions labeled 153*2.0bN*, which precede versions labeled *2.0rcN*, and *those* precede 2.0. 154 155You may also find version numbers with a "+" suffix, e.g. "2.2+". These are 156unreleased versions, built directly from the CPython development repository. In 157practice, after a final minor release is made, the version is incremented to the 158next minor version, which becomes the "a0" version, e.g. "2.4a0". 159 160See the `Developer's Guide 161<https://devguide.python.org/developer-workflow/development-cycle/>`__ 162for more information about the development cycle, and 163:pep:`387` to learn more about Python's backward compatibility policy. See also 164the documentation for :data:`sys.version`, :data:`sys.hexversion`, and 165:data:`sys.version_info`. 166 167 168How do I obtain a copy of the Python source? 169-------------------------------------------- 170 171The latest Python source distribution is always available from python.org, at 172https://www.python.org/downloads/. The latest development sources can be obtained 173at https://github.com/python/cpython/. 174 175The source distribution is a gzipped tar file containing the complete C source, 176Sphinx-formatted documentation, Python library modules, example programs, and 177several useful pieces of freely distributable software. The source will compile 178and run out of the box on most UNIX platforms. 179 180Consult the `Getting Started section of the Python Developer's Guide 181<https://devguide.python.org/setup/>`__ for more 182information on getting the source code and compiling it. 183 184 185How do I get documentation on Python? 186------------------------------------- 187 188The standard documentation for the current stable version of Python is available 189at https://docs.python.org/3/. PDF, plain text, and downloadable HTML versions are 190also available at https://docs.python.org/3/download.html. 191 192The documentation is written in reStructuredText and processed by `the Sphinx 193documentation tool <https://www.sphinx-doc.org/>`__. The reStructuredText source for 194the documentation is part of the Python source distribution. 195 196 197I've never programmed before. Is there a Python tutorial? 198--------------------------------------------------------- 199 200There are numerous tutorials and books available. The standard documentation 201includes :ref:`tutorial-index`. 202 203Consult `the Beginner's Guide <https://wiki.python.org/moin/BeginnersGuide>`_ to 204find information for beginning Python programmers, including lists of tutorials. 205 206 207Is there a newsgroup or mailing list devoted to Python? 208------------------------------------------------------- 209 210There is a newsgroup, :newsgroup:`comp.lang.python`, and a mailing list, 211`python-list <https://mail.python.org/mailman/listinfo/python-list>`_. The 212newsgroup and mailing list are gatewayed into each other -- if you can read news 213it's unnecessary to subscribe to the mailing list. 214:newsgroup:`comp.lang.python` is high-traffic, receiving hundreds of postings 215every day, and Usenet readers are often more able to cope with this volume. 216 217Announcements of new software releases and events can be found in 218comp.lang.python.announce, a low-traffic moderated list that receives about five 219postings per day. It's available as `the python-announce mailing list 220<https://mail.python.org/mailman3/lists/python-announce-list.python.org/>`_. 221 222More info about other mailing lists and newsgroups 223can be found at https://www.python.org/community/lists/. 224 225 226How do I get a beta test version of Python? 227------------------------------------------- 228 229Alpha and beta releases are available from https://www.python.org/downloads/. All 230releases are announced on the comp.lang.python and comp.lang.python.announce 231newsgroups and on the Python home page at https://www.python.org/; an RSS feed of 232news is available. 233 234You can also access the development version of Python through Git. See 235`The Python Developer's Guide <https://devguide.python.org/>`_ for details. 236 237 238How do I submit bug reports and patches for Python? 239--------------------------------------------------- 240 241To report a bug or submit a patch, use the issue tracker at 242https://github.com/python/cpython/issues. 243 244For more information on how Python is developed, consult `the Python Developer's 245Guide <https://devguide.python.org/>`_. 246 247 248Are there any published articles about Python that I can reference? 249------------------------------------------------------------------- 250 251It's probably best to cite your favorite book about Python. 252 253The `very first article <https://ir.cwi.nl/pub/18204>`_ about Python was 254written in 1991 and is now quite outdated. 255 256 Guido van Rossum and Jelke de Boer, "Interactively Testing Remote Servers 257 Using the Python Programming Language", CWI Quarterly, Volume 4, Issue 4 258 (December 1991), Amsterdam, pp 283--303. 259 260 261Are there any books on Python? 262------------------------------ 263 264Yes, there are many, and more are being published. See the python.org wiki at 265https://wiki.python.org/moin/PythonBooks for a list. 266 267You can also search online bookstores for "Python" and filter out the Monty 268Python references; or perhaps search for "Python" and "language". 269 270 271Where in the world is www.python.org located? 272--------------------------------------------- 273 274The Python project's infrastructure is located all over the world and is managed 275by the Python Infrastructure Team. Details `here <https://infra.psf.io>`__. 276 277 278Why is it called Python? 279------------------------ 280 281When he began implementing Python, Guido van Rossum was also reading the 282published scripts from `"Monty Python's Flying Circus" 283<https://en.wikipedia.org/wiki/Monty_Python>`__, a BBC comedy series from the 1970s. Van Rossum 284thought he needed a name that was short, unique, and slightly mysterious, so he 285decided to call the language Python. 286 287 288Do I have to like "Monty Python's Flying Circus"? 289------------------------------------------------- 290 291No, but it helps. :) 292 293 294Python in the real world 295======================== 296 297How stable is Python? 298--------------------- 299 300Very stable. New, stable releases have been coming out roughly every 6 to 18 301months since 1991, and this seems likely to continue. As of version 3.9, 302Python will have a new feature release every 12 months (:pep:`602`). 303 304The developers issue bugfix releases of older versions, so the stability of 305existing releases gradually improves. Bugfix releases, indicated by a third 306component of the version number (e.g. 3.5.3, 3.6.2), are managed for stability; 307only fixes for known problems are included in a bugfix release, and it's 308guaranteed that interfaces will remain the same throughout a series of bugfix 309releases. 310 311The latest stable releases can always be found on the `Python download page 312<https://www.python.org/downloads/>`_. 313Python 3.x is the recommended version and supported by most widely used libraries. 314Python 2.x :pep:`is not maintained anymore <373>`. 315 316 317How many people are using Python? 318--------------------------------- 319 320There are probably millions of users, though it's difficult to obtain an exact 321count. 322 323Python is available for free download, so there are no sales figures, and it's 324available from many different sites and packaged with many Linux distributions, 325so download statistics don't tell the whole story either. 326 327The comp.lang.python newsgroup is very active, but not all Python users post to 328the group or even read it. 329 330 331Have any significant projects been done in Python? 332-------------------------------------------------- 333 334See https://www.python.org/about/success for a list of projects that use Python. 335Consulting the proceedings for `past Python conferences 336<https://www.python.org/community/workshops/>`_ will reveal contributions from many 337different companies and organizations. 338 339High-profile Python projects include `the Mailman mailing list manager 340<https://www.list.org>`_ and `the Zope application server 341<https://www.zope.dev>`_. Several Linux distributions, most notably `Red Hat 342<https://www.redhat.com>`_, have written part or all of their installer and 343system administration software in Python. Companies that use Python internally 344include Google, Yahoo, and Lucasfilm Ltd. 345 346 347What new developments are expected for Python in the future? 348------------------------------------------------------------ 349 350See https://peps.python.org/ for the Python Enhancement Proposals 351(PEPs). PEPs are design documents describing a suggested new feature for Python, 352providing a concise technical specification and a rationale. Look for a PEP 353titled "Python X.Y Release Schedule", where X.Y is a version that hasn't been 354publicly released yet. 355 356New development is discussed on `the python-dev mailing list 357<https://mail.python.org/mailman3/lists/python-dev.python.org/>`_. 358 359 360Is it reasonable to propose incompatible changes to Python? 361----------------------------------------------------------- 362 363In general, no. There are already millions of lines of Python code around the 364world, so any change in the language that invalidates more than a very small 365fraction of existing programs has to be frowned upon. Even if you can provide a 366conversion program, there's still the problem of updating all documentation; 367many books have been written about Python, and we don't want to invalidate them 368all at a single stroke. 369 370Providing a gradual upgrade path is necessary if a feature has to be changed. 371:pep:`5` describes the procedure followed for introducing backward-incompatible 372changes while minimizing disruption for users. 373 374 375Is Python a good language for beginning programmers? 376---------------------------------------------------- 377 378Yes. 379 380It is still common to start students with a procedural and statically typed 381language such as Pascal, C, or a subset of C++ or Java. Students may be better 382served by learning Python as their first language. Python has a very simple and 383consistent syntax and a large standard library and, most importantly, using 384Python in a beginning programming course lets students concentrate on important 385programming skills such as problem decomposition and data type design. With 386Python, students can be quickly introduced to basic concepts such as loops and 387procedures. They can probably even work with user-defined objects in their very 388first course. 389 390For a student who has never programmed before, using a statically typed language 391seems unnatural. It presents additional complexity that the student must master 392and slows the pace of the course. The students are trying to learn to think 393like a computer, decompose problems, design consistent interfaces, and 394encapsulate data. While learning to use a statically typed language is 395important in the long term, it is not necessarily the best topic to address in 396the students' first programming course. 397 398Many other aspects of Python make it a good first language. Like Java, Python 399has a large standard library so that students can be assigned programming 400projects very early in the course that *do* something. Assignments aren't 401restricted to the standard four-function calculator and check balancing 402programs. By using the standard library, students can gain the satisfaction of 403working on realistic applications as they learn the fundamentals of programming. 404Using the standard library also teaches students about code reuse. Third-party 405modules such as PyGame are also helpful in extending the students' reach. 406 407Python's interactive interpreter enables students to test language features 408while they're programming. They can keep a window with the interpreter running 409while they enter their program's source in another window. If they can't 410remember the methods for a list, they can do something like this:: 411 412 >>> L = [] 413 >>> dir(L) # doctest: +NORMALIZE_WHITESPACE 414 ['__add__', '__class__', '__contains__', '__delattr__', '__delitem__', 415 '__dir__', '__doc__', '__eq__', '__format__', '__ge__', 416 '__getattribute__', '__getitem__', '__gt__', '__hash__', '__iadd__', 417 '__imul__', '__init__', '__iter__', '__le__', '__len__', '__lt__', 418 '__mul__', '__ne__', '__new__', '__reduce__', '__reduce_ex__', 419 '__repr__', '__reversed__', '__rmul__', '__setattr__', '__setitem__', 420 '__sizeof__', '__str__', '__subclasshook__', 'append', 'clear', 421 'copy', 'count', 'extend', 'index', 'insert', 'pop', 'remove', 422 'reverse', 'sort'] 423 >>> [d for d in dir(L) if '__' not in d] 424 ['append', 'clear', 'copy', 'count', 'extend', 'index', 'insert', 'pop', 'remove', 'reverse', 'sort'] 425 426 >>> help(L.append) 427 Help on built-in function append: 428 <BLANKLINE> 429 append(...) 430 L.append(object) -> None -- append object to end 431 <BLANKLINE> 432 >>> L.append(1) 433 >>> L 434 [1] 435 436With the interpreter, documentation is never far from the student as they are 437programming. 438 439There are also good IDEs for Python. IDLE is a cross-platform IDE for Python 440that is written in Python using Tkinter. 441Emacs users will be happy to know that there is a very good Python mode for 442Emacs. All of these programming environments provide syntax highlighting, 443auto-indenting, and access to the interactive interpreter while coding. Consult 444`the Python wiki <https://wiki.python.org/moin/PythonEditors>`_ for a full list 445of Python editing environments. 446 447If you want to discuss Python's use in education, you may be interested in 448joining `the edu-sig mailing list 449<https://www.python.org/community/sigs/current/edu-sig>`_. 450