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