You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

543 lines
18 KiB

Merged revisions 74277,74321,74323,74326,74355,74465,74467,74488,74492,74513,74531,74549,74553,74625,74632,74643-74644,74647,74652,74666,74671,74727,74739 via svnmerge from svn+ssh://pythondev@svn.python.org/python/trunk ........ r74277 | sean.reifschneider | 2009-08-01 18:54:55 -0500 (Sat, 01 Aug 2009) | 3 lines - Issue #6624: yArg_ParseTuple with "s" format when parsing argument with NUL: Bogus TypeError detail string. ........ r74321 | guilherme.polo | 2009-08-05 11:51:41 -0500 (Wed, 05 Aug 2009) | 1 line Easier reference to find (at least while svn continues being used). ........ r74323 | guilherme.polo | 2009-08-05 18:48:26 -0500 (Wed, 05 Aug 2009) | 1 line Typo. ........ r74326 | jesse.noller | 2009-08-05 21:05:56 -0500 (Wed, 05 Aug 2009) | 1 line Fix issue 4660: spurious task_done errors in multiprocessing, remove doc note for from_address ........ r74355 | gregory.p.smith | 2009-08-12 12:02:37 -0500 (Wed, 12 Aug 2009) | 2 lines comment typo fix ........ r74465 | vinay.sajip | 2009-08-15 18:23:12 -0500 (Sat, 15 Aug 2009) | 1 line Added section on logging to one file from multiple processes. ........ r74467 | vinay.sajip | 2009-08-15 18:34:47 -0500 (Sat, 15 Aug 2009) | 1 line Refined section on logging to one file from multiple processes. ........ r74488 | vinay.sajip | 2009-08-17 08:14:37 -0500 (Mon, 17 Aug 2009) | 1 line Further refined section on logging to one file from multiple processes. ........ r74492 | r.david.murray | 2009-08-17 14:26:49 -0500 (Mon, 17 Aug 2009) | 2 lines Issue 6685: 'toupper' -> 'upper' in cgi doc example explanation. ........ r74513 | skip.montanaro | 2009-08-18 09:37:52 -0500 (Tue, 18 Aug 2009) | 1 line missing module ref (issue6723) ........ r74531 | vinay.sajip | 2009-08-20 17:04:32 -0500 (Thu, 20 Aug 2009) | 1 line Added section on exceptions raised during logging. ........ r74549 | benjamin.peterson | 2009-08-24 12:42:36 -0500 (Mon, 24 Aug 2009) | 1 line fix pdf building by teaching latex the right encoding package ........ r74553 | r.david.murray | 2009-08-26 20:04:59 -0500 (Wed, 26 Aug 2009) | 2 lines Remove leftover text from end of sentence. ........ r74625 | benjamin.peterson | 2009-09-01 17:27:57 -0500 (Tue, 01 Sep 2009) | 1 line remove the check that classmethod's argument is a callable ........ r74632 | georg.brandl | 2009-09-03 02:27:26 -0500 (Thu, 03 Sep 2009) | 1 line #6828: fix wrongly highlighted blocks. ........ r74643 | georg.brandl | 2009-09-04 01:59:20 -0500 (Fri, 04 Sep 2009) | 2 lines Issue #2666: Handle BROWSER environment variable properly for unknown browser names in the webbrowser module. ........ r74644 | georg.brandl | 2009-09-04 02:55:14 -0500 (Fri, 04 Sep 2009) | 1 line #5047: remove Monterey support from configure. ........ r74647 | georg.brandl | 2009-09-04 03:17:04 -0500 (Fri, 04 Sep 2009) | 2 lines Issue #5275: In Cookie's Cookie.load(), properly handle non-string arguments as documented. ........ r74652 | georg.brandl | 2009-09-04 06:25:37 -0500 (Fri, 04 Sep 2009) | 1 line #6756: add some info about the "acct" parameter. ........ r74666 | georg.brandl | 2009-09-05 04:04:09 -0500 (Sat, 05 Sep 2009) | 1 line #6841: remove duplicated word. ........ r74671 | georg.brandl | 2009-09-05 11:47:17 -0500 (Sat, 05 Sep 2009) | 1 line #6843: add link from filterwarnings to where the meaning of the arguments is covered. ........ r74727 | benjamin.peterson | 2009-09-08 18:04:22 -0500 (Tue, 08 Sep 2009) | 1 line #6865 fix ref counting in initialization of pwd module ........ r74739 | georg.brandl | 2009-09-11 02:55:20 -0500 (Fri, 11 Sep 2009) | 1 line Move function back to its section. ........
17 years ago
15 years ago
Merged revisions 74277,74321,74323,74326,74355,74465,74467,74488,74492,74513,74531,74549,74553,74625,74632,74643-74644,74647,74652,74666,74671,74727,74739 via svnmerge from svn+ssh://pythondev@svn.python.org/python/trunk ........ r74277 | sean.reifschneider | 2009-08-01 18:54:55 -0500 (Sat, 01 Aug 2009) | 3 lines - Issue #6624: yArg_ParseTuple with "s" format when parsing argument with NUL: Bogus TypeError detail string. ........ r74321 | guilherme.polo | 2009-08-05 11:51:41 -0500 (Wed, 05 Aug 2009) | 1 line Easier reference to find (at least while svn continues being used). ........ r74323 | guilherme.polo | 2009-08-05 18:48:26 -0500 (Wed, 05 Aug 2009) | 1 line Typo. ........ r74326 | jesse.noller | 2009-08-05 21:05:56 -0500 (Wed, 05 Aug 2009) | 1 line Fix issue 4660: spurious task_done errors in multiprocessing, remove doc note for from_address ........ r74355 | gregory.p.smith | 2009-08-12 12:02:37 -0500 (Wed, 12 Aug 2009) | 2 lines comment typo fix ........ r74465 | vinay.sajip | 2009-08-15 18:23:12 -0500 (Sat, 15 Aug 2009) | 1 line Added section on logging to one file from multiple processes. ........ r74467 | vinay.sajip | 2009-08-15 18:34:47 -0500 (Sat, 15 Aug 2009) | 1 line Refined section on logging to one file from multiple processes. ........ r74488 | vinay.sajip | 2009-08-17 08:14:37 -0500 (Mon, 17 Aug 2009) | 1 line Further refined section on logging to one file from multiple processes. ........ r74492 | r.david.murray | 2009-08-17 14:26:49 -0500 (Mon, 17 Aug 2009) | 2 lines Issue 6685: 'toupper' -> 'upper' in cgi doc example explanation. ........ r74513 | skip.montanaro | 2009-08-18 09:37:52 -0500 (Tue, 18 Aug 2009) | 1 line missing module ref (issue6723) ........ r74531 | vinay.sajip | 2009-08-20 17:04:32 -0500 (Thu, 20 Aug 2009) | 1 line Added section on exceptions raised during logging. ........ r74549 | benjamin.peterson | 2009-08-24 12:42:36 -0500 (Mon, 24 Aug 2009) | 1 line fix pdf building by teaching latex the right encoding package ........ r74553 | r.david.murray | 2009-08-26 20:04:59 -0500 (Wed, 26 Aug 2009) | 2 lines Remove leftover text from end of sentence. ........ r74625 | benjamin.peterson | 2009-09-01 17:27:57 -0500 (Tue, 01 Sep 2009) | 1 line remove the check that classmethod's argument is a callable ........ r74632 | georg.brandl | 2009-09-03 02:27:26 -0500 (Thu, 03 Sep 2009) | 1 line #6828: fix wrongly highlighted blocks. ........ r74643 | georg.brandl | 2009-09-04 01:59:20 -0500 (Fri, 04 Sep 2009) | 2 lines Issue #2666: Handle BROWSER environment variable properly for unknown browser names in the webbrowser module. ........ r74644 | georg.brandl | 2009-09-04 02:55:14 -0500 (Fri, 04 Sep 2009) | 1 line #5047: remove Monterey support from configure. ........ r74647 | georg.brandl | 2009-09-04 03:17:04 -0500 (Fri, 04 Sep 2009) | 2 lines Issue #5275: In Cookie's Cookie.load(), properly handle non-string arguments as documented. ........ r74652 | georg.brandl | 2009-09-04 06:25:37 -0500 (Fri, 04 Sep 2009) | 1 line #6756: add some info about the "acct" parameter. ........ r74666 | georg.brandl | 2009-09-05 04:04:09 -0500 (Sat, 05 Sep 2009) | 1 line #6841: remove duplicated word. ........ r74671 | georg.brandl | 2009-09-05 11:47:17 -0500 (Sat, 05 Sep 2009) | 1 line #6843: add link from filterwarnings to where the meaning of the arguments is covered. ........ r74727 | benjamin.peterson | 2009-09-08 18:04:22 -0500 (Tue, 08 Sep 2009) | 1 line #6865 fix ref counting in initialization of pwd module ........ r74739 | georg.brandl | 2009-09-11 02:55:20 -0500 (Fri, 11 Sep 2009) | 1 line Move function back to its section. ........
17 years ago
Merged revisions 74277,74321,74323,74326,74355,74465,74467,74488,74492,74513,74531,74549,74553,74625,74632,74643-74644,74647,74652,74666,74671,74727,74739 via svnmerge from svn+ssh://pythondev@svn.python.org/python/trunk ........ r74277 | sean.reifschneider | 2009-08-01 18:54:55 -0500 (Sat, 01 Aug 2009) | 3 lines - Issue #6624: yArg_ParseTuple with "s" format when parsing argument with NUL: Bogus TypeError detail string. ........ r74321 | guilherme.polo | 2009-08-05 11:51:41 -0500 (Wed, 05 Aug 2009) | 1 line Easier reference to find (at least while svn continues being used). ........ r74323 | guilherme.polo | 2009-08-05 18:48:26 -0500 (Wed, 05 Aug 2009) | 1 line Typo. ........ r74326 | jesse.noller | 2009-08-05 21:05:56 -0500 (Wed, 05 Aug 2009) | 1 line Fix issue 4660: spurious task_done errors in multiprocessing, remove doc note for from_address ........ r74355 | gregory.p.smith | 2009-08-12 12:02:37 -0500 (Wed, 12 Aug 2009) | 2 lines comment typo fix ........ r74465 | vinay.sajip | 2009-08-15 18:23:12 -0500 (Sat, 15 Aug 2009) | 1 line Added section on logging to one file from multiple processes. ........ r74467 | vinay.sajip | 2009-08-15 18:34:47 -0500 (Sat, 15 Aug 2009) | 1 line Refined section on logging to one file from multiple processes. ........ r74488 | vinay.sajip | 2009-08-17 08:14:37 -0500 (Mon, 17 Aug 2009) | 1 line Further refined section on logging to one file from multiple processes. ........ r74492 | r.david.murray | 2009-08-17 14:26:49 -0500 (Mon, 17 Aug 2009) | 2 lines Issue 6685: 'toupper' -> 'upper' in cgi doc example explanation. ........ r74513 | skip.montanaro | 2009-08-18 09:37:52 -0500 (Tue, 18 Aug 2009) | 1 line missing module ref (issue6723) ........ r74531 | vinay.sajip | 2009-08-20 17:04:32 -0500 (Thu, 20 Aug 2009) | 1 line Added section on exceptions raised during logging. ........ r74549 | benjamin.peterson | 2009-08-24 12:42:36 -0500 (Mon, 24 Aug 2009) | 1 line fix pdf building by teaching latex the right encoding package ........ r74553 | r.david.murray | 2009-08-26 20:04:59 -0500 (Wed, 26 Aug 2009) | 2 lines Remove leftover text from end of sentence. ........ r74625 | benjamin.peterson | 2009-09-01 17:27:57 -0500 (Tue, 01 Sep 2009) | 1 line remove the check that classmethod's argument is a callable ........ r74632 | georg.brandl | 2009-09-03 02:27:26 -0500 (Thu, 03 Sep 2009) | 1 line #6828: fix wrongly highlighted blocks. ........ r74643 | georg.brandl | 2009-09-04 01:59:20 -0500 (Fri, 04 Sep 2009) | 2 lines Issue #2666: Handle BROWSER environment variable properly for unknown browser names in the webbrowser module. ........ r74644 | georg.brandl | 2009-09-04 02:55:14 -0500 (Fri, 04 Sep 2009) | 1 line #5047: remove Monterey support from configure. ........ r74647 | georg.brandl | 2009-09-04 03:17:04 -0500 (Fri, 04 Sep 2009) | 2 lines Issue #5275: In Cookie's Cookie.load(), properly handle non-string arguments as documented. ........ r74652 | georg.brandl | 2009-09-04 06:25:37 -0500 (Fri, 04 Sep 2009) | 1 line #6756: add some info about the "acct" parameter. ........ r74666 | georg.brandl | 2009-09-05 04:04:09 -0500 (Sat, 05 Sep 2009) | 1 line #6841: remove duplicated word. ........ r74671 | georg.brandl | 2009-09-05 11:47:17 -0500 (Sat, 05 Sep 2009) | 1 line #6843: add link from filterwarnings to where the meaning of the arguments is covered. ........ r74727 | benjamin.peterson | 2009-09-08 18:04:22 -0500 (Tue, 08 Sep 2009) | 1 line #6865 fix ref counting in initialization of pwd module ........ r74739 | georg.brandl | 2009-09-11 02:55:20 -0500 (Fri, 11 Sep 2009) | 1 line Move function back to its section. ........
17 years ago
Merged revisions 74277,74321,74323,74326,74355,74465,74467,74488,74492,74513,74531,74549,74553,74625,74632,74643-74644,74647,74652,74666,74671,74727,74739 via svnmerge from svn+ssh://pythondev@svn.python.org/python/trunk ........ r74277 | sean.reifschneider | 2009-08-01 18:54:55 -0500 (Sat, 01 Aug 2009) | 3 lines - Issue #6624: yArg_ParseTuple with "s" format when parsing argument with NUL: Bogus TypeError detail string. ........ r74321 | guilherme.polo | 2009-08-05 11:51:41 -0500 (Wed, 05 Aug 2009) | 1 line Easier reference to find (at least while svn continues being used). ........ r74323 | guilherme.polo | 2009-08-05 18:48:26 -0500 (Wed, 05 Aug 2009) | 1 line Typo. ........ r74326 | jesse.noller | 2009-08-05 21:05:56 -0500 (Wed, 05 Aug 2009) | 1 line Fix issue 4660: spurious task_done errors in multiprocessing, remove doc note for from_address ........ r74355 | gregory.p.smith | 2009-08-12 12:02:37 -0500 (Wed, 12 Aug 2009) | 2 lines comment typo fix ........ r74465 | vinay.sajip | 2009-08-15 18:23:12 -0500 (Sat, 15 Aug 2009) | 1 line Added section on logging to one file from multiple processes. ........ r74467 | vinay.sajip | 2009-08-15 18:34:47 -0500 (Sat, 15 Aug 2009) | 1 line Refined section on logging to one file from multiple processes. ........ r74488 | vinay.sajip | 2009-08-17 08:14:37 -0500 (Mon, 17 Aug 2009) | 1 line Further refined section on logging to one file from multiple processes. ........ r74492 | r.david.murray | 2009-08-17 14:26:49 -0500 (Mon, 17 Aug 2009) | 2 lines Issue 6685: 'toupper' -> 'upper' in cgi doc example explanation. ........ r74513 | skip.montanaro | 2009-08-18 09:37:52 -0500 (Tue, 18 Aug 2009) | 1 line missing module ref (issue6723) ........ r74531 | vinay.sajip | 2009-08-20 17:04:32 -0500 (Thu, 20 Aug 2009) | 1 line Added section on exceptions raised during logging. ........ r74549 | benjamin.peterson | 2009-08-24 12:42:36 -0500 (Mon, 24 Aug 2009) | 1 line fix pdf building by teaching latex the right encoding package ........ r74553 | r.david.murray | 2009-08-26 20:04:59 -0500 (Wed, 26 Aug 2009) | 2 lines Remove leftover text from end of sentence. ........ r74625 | benjamin.peterson | 2009-09-01 17:27:57 -0500 (Tue, 01 Sep 2009) | 1 line remove the check that classmethod's argument is a callable ........ r74632 | georg.brandl | 2009-09-03 02:27:26 -0500 (Thu, 03 Sep 2009) | 1 line #6828: fix wrongly highlighted blocks. ........ r74643 | georg.brandl | 2009-09-04 01:59:20 -0500 (Fri, 04 Sep 2009) | 2 lines Issue #2666: Handle BROWSER environment variable properly for unknown browser names in the webbrowser module. ........ r74644 | georg.brandl | 2009-09-04 02:55:14 -0500 (Fri, 04 Sep 2009) | 1 line #5047: remove Monterey support from configure. ........ r74647 | georg.brandl | 2009-09-04 03:17:04 -0500 (Fri, 04 Sep 2009) | 2 lines Issue #5275: In Cookie's Cookie.load(), properly handle non-string arguments as documented. ........ r74652 | georg.brandl | 2009-09-04 06:25:37 -0500 (Fri, 04 Sep 2009) | 1 line #6756: add some info about the "acct" parameter. ........ r74666 | georg.brandl | 2009-09-05 04:04:09 -0500 (Sat, 05 Sep 2009) | 1 line #6841: remove duplicated word. ........ r74671 | georg.brandl | 2009-09-05 11:47:17 -0500 (Sat, 05 Sep 2009) | 1 line #6843: add link from filterwarnings to where the meaning of the arguments is covered. ........ r74727 | benjamin.peterson | 2009-09-08 18:04:22 -0500 (Tue, 08 Sep 2009) | 1 line #6865 fix ref counting in initialization of pwd module ........ r74739 | georg.brandl | 2009-09-11 02:55:20 -0500 (Fri, 11 Sep 2009) | 1 line Move function back to its section. ........
17 years ago
Merged revisions 78966,78970,79018,79026-79027,79055,79156,79159,79163-79164,79173,79176,79194,79208,79212 via svnmerge from svn+ssh://pythondev@svn.python.org/python/trunk ........ r78966 | florent.xicluna | 2010-03-14 10:20:59 -0500 (Sun, 14 Mar 2010) | 2 lines Do not hardcode Expat version. It's possible to build Python with --with-system-expat option. ........ r78970 | benjamin.peterson | 2010-03-14 21:58:24 -0500 (Sun, 14 Mar 2010) | 1 line this little exception dance is pointless ........ r79018 | collin.winter | 2010-03-16 22:04:01 -0500 (Tue, 16 Mar 2010) | 1 line Delete unused import. ........ r79026 | vinay.sajip | 2010-03-17 10:05:57 -0500 (Wed, 17 Mar 2010) | 1 line Issue #8162: logging: Clarified docstring and documentation for disable function. ........ r79027 | collin.winter | 2010-03-17 12:36:16 -0500 (Wed, 17 Mar 2010) | 1 line Avoid hardcoding refcounts in tests. ........ r79055 | benjamin.peterson | 2010-03-18 16:30:48 -0500 (Thu, 18 Mar 2010) | 1 line remove installation of deleted test/output dir ........ r79156 | florent.xicluna | 2010-03-20 17:21:02 -0500 (Sat, 20 Mar 2010) | 2 lines Cleanup test_struct using check_warnings. ........ r79159 | florent.xicluna | 2010-03-20 17:26:42 -0500 (Sat, 20 Mar 2010) | 2 lines Cleanup test_tarfile, and use check_warnings. ........ r79163 | michael.foord | 2010-03-20 19:53:39 -0500 (Sat, 20 Mar 2010) | 1 line A faulty load_tests in a test module no longer halts test discovery. A placeholder test, that reports the failure, is created instead. ........ r79164 | michael.foord | 2010-03-20 19:55:58 -0500 (Sat, 20 Mar 2010) | 1 line Change order of arguments in a unittest function. ........ r79173 | georg.brandl | 2010-03-21 04:09:38 -0500 (Sun, 21 Mar 2010) | 1 line Document that GzipFile supports iteration. ........ r79176 | georg.brandl | 2010-03-21 04:17:41 -0500 (Sun, 21 Mar 2010) | 1 line Introduce copy by slicing, used in later chapters. ........ r79194 | florent.xicluna | 2010-03-21 06:58:11 -0500 (Sun, 21 Mar 2010) | 2 lines Use assertRaises and add a specific warning filter. ........ r79208 | andrew.kuchling | 2010-03-21 13:47:12 -0500 (Sun, 21 Mar 2010) | 1 line Add items ........ r79212 | georg.brandl | 2010-03-21 14:01:38 -0500 (Sun, 21 Mar 2010) | 1 line Fix plural. ........
16 years ago
Merged revisions 78966,78970,79018,79026-79027,79055,79156,79159,79163-79164,79173,79176,79194,79208,79212 via svnmerge from svn+ssh://pythondev@svn.python.org/python/trunk ........ r78966 | florent.xicluna | 2010-03-14 10:20:59 -0500 (Sun, 14 Mar 2010) | 2 lines Do not hardcode Expat version. It's possible to build Python with --with-system-expat option. ........ r78970 | benjamin.peterson | 2010-03-14 21:58:24 -0500 (Sun, 14 Mar 2010) | 1 line this little exception dance is pointless ........ r79018 | collin.winter | 2010-03-16 22:04:01 -0500 (Tue, 16 Mar 2010) | 1 line Delete unused import. ........ r79026 | vinay.sajip | 2010-03-17 10:05:57 -0500 (Wed, 17 Mar 2010) | 1 line Issue #8162: logging: Clarified docstring and documentation for disable function. ........ r79027 | collin.winter | 2010-03-17 12:36:16 -0500 (Wed, 17 Mar 2010) | 1 line Avoid hardcoding refcounts in tests. ........ r79055 | benjamin.peterson | 2010-03-18 16:30:48 -0500 (Thu, 18 Mar 2010) | 1 line remove installation of deleted test/output dir ........ r79156 | florent.xicluna | 2010-03-20 17:21:02 -0500 (Sat, 20 Mar 2010) | 2 lines Cleanup test_struct using check_warnings. ........ r79159 | florent.xicluna | 2010-03-20 17:26:42 -0500 (Sat, 20 Mar 2010) | 2 lines Cleanup test_tarfile, and use check_warnings. ........ r79163 | michael.foord | 2010-03-20 19:53:39 -0500 (Sat, 20 Mar 2010) | 1 line A faulty load_tests in a test module no longer halts test discovery. A placeholder test, that reports the failure, is created instead. ........ r79164 | michael.foord | 2010-03-20 19:55:58 -0500 (Sat, 20 Mar 2010) | 1 line Change order of arguments in a unittest function. ........ r79173 | georg.brandl | 2010-03-21 04:09:38 -0500 (Sun, 21 Mar 2010) | 1 line Document that GzipFile supports iteration. ........ r79176 | georg.brandl | 2010-03-21 04:17:41 -0500 (Sun, 21 Mar 2010) | 1 line Introduce copy by slicing, used in later chapters. ........ r79194 | florent.xicluna | 2010-03-21 06:58:11 -0500 (Sun, 21 Mar 2010) | 2 lines Use assertRaises and add a specific warning filter. ........ r79208 | andrew.kuchling | 2010-03-21 13:47:12 -0500 (Sun, 21 Mar 2010) | 1 line Add items ........ r79212 | georg.brandl | 2010-03-21 14:01:38 -0500 (Sun, 21 Mar 2010) | 1 line Fix plural. ........
16 years ago
Merged revisions 58886-58929 via svnmerge from svn+ssh://pythondev@svn.python.org/python/trunk ........ r58892 | guido.van.rossum | 2007-11-06 15:32:56 -0800 (Tue, 06 Nov 2007) | 2 lines Add missing "return NULL" in overflow check in PyObject_Repr(). ........ r58893 | raymond.hettinger | 2007-11-06 17:13:09 -0800 (Tue, 06 Nov 2007) | 1 line Fix marshal's incorrect handling of subclasses of builtin types (backport candidate). ........ r58895 | raymond.hettinger | 2007-11-06 18:26:17 -0800 (Tue, 06 Nov 2007) | 1 line Optimize dict.fromkeys() with dict inputs. Useful for resetting bag/muliset counts for example. ........ r58896 | raymond.hettinger | 2007-11-06 18:45:46 -0800 (Tue, 06 Nov 2007) | 1 line Add build option for faster loop execution. ........ r58900 | nick.coghlan | 2007-11-07 03:57:51 -0800 (Wed, 07 Nov 2007) | 1 line Add missing NEWS entry ........ r58905 | christian.heimes | 2007-11-07 09:50:54 -0800 (Wed, 07 Nov 2007) | 1 line Backported fix for bug #1392 from py3k branch r58903. ........ r58906 | christian.heimes | 2007-11-07 10:30:22 -0800 (Wed, 07 Nov 2007) | 1 line Backport of Guido's review of my patch. ........ r58908 | raymond.hettinger | 2007-11-07 18:52:43 -0800 (Wed, 07 Nov 2007) | 1 line Add set.isdisjoint() ........ r58915 | raymond.hettinger | 2007-11-08 10:47:51 -0800 (Thu, 08 Nov 2007) | 1 line Reposition the decref (spotted by eagle-eye norwitz). ........ r58920 | georg.brandl | 2007-11-09 04:31:43 -0800 (Fri, 09 Nov 2007) | 2 lines Fix seealso link to sets docs. Do not merge to Py3k. ........ r58921 | georg.brandl | 2007-11-09 05:08:48 -0800 (Fri, 09 Nov 2007) | 2 lines Fix misleading example. ........ r58923 | georg.brandl | 2007-11-09 09:33:23 -0800 (Fri, 09 Nov 2007) | 3 lines Correct a comment about testing methods - nowadays most tests don't run directly on import. ........ r58924 | martin.v.loewis | 2007-11-09 14:56:30 -0800 (Fri, 09 Nov 2007) | 2 lines Add Amaury Forgeot d'Arc. ........ r58925 | raymond.hettinger | 2007-11-09 15:14:44 -0800 (Fri, 09 Nov 2007) | 1 line Optimize common case for dict.fromkeys(). ........ r58927 | raymond.hettinger | 2007-11-09 17:54:03 -0800 (Fri, 09 Nov 2007) | 1 line Use a freelist to speed-up block allocation and deallocation in collections.deque(). ........ r58929 | guido.van.rossum | 2007-11-10 14:12:24 -0800 (Sat, 10 Nov 2007) | 3 lines Issue 1416. Add getter, setter, deleter methods to properties that can be used as decorators to create fully-populated properties. ........
18 years ago
18 years ago
  1. .. _tut-informal:
  2. **********************************
  3. An Informal Introduction to Python
  4. **********************************
  5. In the following examples, input and output are distinguished by the presence or
  6. absence of prompts (:term:`>>>` and :term:`...`): to repeat the example, you must type
  7. everything after the prompt, when the prompt appears; lines that do not begin
  8. with a prompt are output from the interpreter. Note that a secondary prompt on a
  9. line by itself in an example means you must type a blank line; this is used to
  10. end a multi-line command.
  11. Many of the examples in this manual, even those entered at the interactive
  12. prompt, include comments. Comments in Python start with the hash character,
  13. ``#``, and extend to the end of the physical line. A comment may appear at the
  14. start of a line or following whitespace or code, but not within a string
  15. literal. A hash character within a string literal is just a hash character.
  16. Since comments are to clarify code and are not interpreted by Python, they may
  17. be omitted when typing in examples.
  18. Some examples::
  19. # this is the first comment
  20. spam = 1 # and this is the second comment
  21. # ... and now a third!
  22. text = "# This is not a comment because it's inside quotes."
  23. .. _tut-calculator:
  24. Using Python as a Calculator
  25. ============================
  26. Let's try some simple Python commands. Start the interpreter and wait for the
  27. primary prompt, ``>>>``. (It shouldn't take long.)
  28. .. _tut-numbers:
  29. Numbers
  30. -------
  31. The interpreter acts as a simple calculator: you can type an expression at it
  32. and it will write the value. Expression syntax is straightforward: the
  33. operators ``+``, ``-``, ``*`` and ``/`` work just like in most other languages
  34. (for example, Pascal or C); parentheses (``()``) can be used for grouping.
  35. For example::
  36. >>> 2 + 2
  37. 4
  38. >>> 50 - 5*6
  39. 20
  40. >>> (50 - 5*6) / 4
  41. 5.0
  42. >>> 8 / 5 # division always returns a floating point number
  43. 1.6
  44. The integer numbers (e.g. ``2``, ``4``, ``20``) have type :class:`int`,
  45. the ones with a fractional part (e.g. ``5.0``, ``1.6``) have type
  46. :class:`float`. We will see more about numeric types later in the tutorial.
  47. Division (``/``) always returns a float. To do :term:`floor division` and
  48. get an integer result (discarding any fractional result) you can use the ``//``
  49. operator; to calculate the remainder you can use ``%``::
  50. >>> 17 / 3 # classic division returns a float
  51. 5.666666666666667
  52. >>>
  53. >>> 17 // 3 # floor division discards the fractional part
  54. 5
  55. >>> 17 % 3 # the % operator returns the remainder of the division
  56. 2
  57. >>> 5 * 3 + 2 # result * divisor + remainder
  58. 17
  59. With Python, it is possible to use the ``**`` operator to calculate powers [#]_::
  60. >>> 5 ** 2 # 5 squared
  61. 25
  62. >>> 2 ** 7 # 2 to the power of 7
  63. 128
  64. The equal sign (``=``) is used to assign a value to a variable. Afterwards, no
  65. result is displayed before the next interactive prompt::
  66. >>> width = 20
  67. >>> height = 5 * 9
  68. >>> width * height
  69. 900
  70. If a variable is not "defined" (assigned a value), trying to use it will
  71. give you an error::
  72. >>> n # try to access an undefined variable
  73. Traceback (most recent call last):
  74. File "<stdin>", line 1, in <module>
  75. NameError: name 'n' is not defined
  76. There is full support for floating point; operators with mixed type operands
  77. convert the integer operand to floating point::
  78. >>> 4 * 3.75 - 1
  79. 14.0
  80. In interactive mode, the last printed expression is assigned to the variable
  81. ``_``. This means that when you are using Python as a desk calculator, it is
  82. somewhat easier to continue calculations, for example::
  83. >>> tax = 12.5 / 100
  84. >>> price = 100.50
  85. >>> price * tax
  86. 12.5625
  87. >>> price + _
  88. 113.0625
  89. >>> round(_, 2)
  90. 113.06
  91. This variable should be treated as read-only by the user. Don't explicitly
  92. assign a value to it --- you would create an independent local variable with the
  93. same name masking the built-in variable with its magic behavior.
  94. In addition to :class:`int` and :class:`float`, Python supports other types of
  95. numbers, such as :class:`~decimal.Decimal` and :class:`~fractions.Fraction`.
  96. Python also has built-in support for :ref:`complex numbers <typesnumeric>`,
  97. and uses the ``j`` or ``J`` suffix to indicate the imaginary part
  98. (e.g. ``3+5j``).
  99. .. _tut-strings:
  100. Strings
  101. -------
  102. Besides numbers, Python can also manipulate strings, which can be expressed
  103. in several ways. They can be enclosed in single quotes (``'...'``) or
  104. double quotes (``"..."``) with the same result [#]_. ``\`` can be used
  105. to escape quotes::
  106. >>> 'spam eggs' # single quotes
  107. 'spam eggs'
  108. >>> 'doesn\'t' # use \' to escape the single quote...
  109. "doesn't"
  110. >>> "doesn't" # ...or use double quotes instead
  111. "doesn't"
  112. >>> '"Yes," they said.'
  113. '"Yes," they said.'
  114. >>> "\"Yes,\" they said."
  115. '"Yes," they said.'
  116. >>> '"Isn\'t," they said.'
  117. '"Isn\'t," they said.'
  118. In the interactive interpreter, the output string is enclosed in quotes and
  119. special characters are escaped with backslashes. While this might sometimes
  120. look different from the input (the enclosing quotes could change), the two
  121. strings are equivalent. The string is enclosed in double quotes if
  122. the string contains a single quote and no double quotes, otherwise it is
  123. enclosed in single quotes. The :func:`print` function produces a more
  124. readable output, by omitting the enclosing quotes and by printing escaped
  125. and special characters::
  126. >>> '"Isn\'t," they said.'
  127. '"Isn\'t," they said.'
  128. >>> print('"Isn\'t," they said.')
  129. "Isn't," they said.
  130. >>> s = 'First line.\nSecond line.' # \n means newline
  131. >>> s # without print(), \n is included in the output
  132. 'First line.\nSecond line.'
  133. >>> print(s) # with print(), \n produces a new line
  134. First line.
  135. Second line.
  136. If you don't want characters prefaced by ``\`` to be interpreted as
  137. special characters, you can use *raw strings* by adding an ``r`` before
  138. the first quote::
  139. >>> print('C:\some\name') # here \n means newline!
  140. C:\some
  141. ame
  142. >>> print(r'C:\some\name') # note the r before the quote
  143. C:\some\name
  144. String literals can span multiple lines. One way is using triple-quotes:
  145. ``"""..."""`` or ``'''...'''``. End of lines are automatically
  146. included in the string, but it's possible to prevent this by adding a ``\`` at
  147. the end of the line. The following example::
  148. print("""\
  149. Usage: thingy [OPTIONS]
  150. -h Display this usage message
  151. -H hostname Hostname to connect to
  152. """)
  153. produces the following output (note that the initial newline is not included):
  154. .. code-block:: text
  155. Usage: thingy [OPTIONS]
  156. -h Display this usage message
  157. -H hostname Hostname to connect to
  158. Strings can be concatenated (glued together) with the ``+`` operator, and
  159. repeated with ``*``::
  160. >>> # 3 times 'un', followed by 'ium'
  161. >>> 3 * 'un' + 'ium'
  162. 'unununium'
  163. Two or more *string literals* (i.e. the ones enclosed between quotes) next
  164. to each other are automatically concatenated. ::
  165. >>> 'Py' 'thon'
  166. 'Python'
  167. This feature is particularly useful when you want to break long strings::
  168. >>> text = ('Put several strings within parentheses '
  169. ... 'to have them joined together.')
  170. >>> text
  171. 'Put several strings within parentheses to have them joined together.'
  172. This only works with two literals though, not with variables or expressions::
  173. >>> prefix = 'Py'
  174. >>> prefix 'thon' # can't concatenate a variable and a string literal
  175. File "<stdin>", line 1
  176. prefix 'thon'
  177. ^
  178. SyntaxError: invalid syntax
  179. >>> ('un' * 3) 'ium'
  180. File "<stdin>", line 1
  181. ('un' * 3) 'ium'
  182. ^
  183. SyntaxError: invalid syntax
  184. If you want to concatenate variables or a variable and a literal, use ``+``::
  185. >>> prefix + 'thon'
  186. 'Python'
  187. Strings can be *indexed* (subscripted), with the first character having index 0.
  188. There is no separate character type; a character is simply a string of size
  189. one::
  190. >>> word = 'Python'
  191. >>> word[0] # character in position 0
  192. 'P'
  193. >>> word[5] # character in position 5
  194. 'n'
  195. Indices may also be negative numbers, to start counting from the right::
  196. >>> word[-1] # last character
  197. 'n'
  198. >>> word[-2] # second-last character
  199. 'o'
  200. >>> word[-6]
  201. 'P'
  202. Note that since -0 is the same as 0, negative indices start from -1.
  203. In addition to indexing, *slicing* is also supported. While indexing is used
  204. to obtain individual characters, *slicing* allows you to obtain substring::
  205. >>> word[0:2] # characters from position 0 (included) to 2 (excluded)
  206. 'Py'
  207. >>> word[2:5] # characters from position 2 (included) to 5 (excluded)
  208. 'tho'
  209. Note how the start is always included, and the end always excluded. This
  210. makes sure that ``s[:i] + s[i:]`` is always equal to ``s``::
  211. >>> word[:2] + word[2:]
  212. 'Python'
  213. >>> word[:4] + word[4:]
  214. 'Python'
  215. Slice indices have useful defaults; an omitted first index defaults to zero, an
  216. omitted second index defaults to the size of the string being sliced. ::
  217. >>> word[:2] # character from the beginning to position 2 (excluded)
  218. 'Py'
  219. >>> word[4:] # characters from position 4 (included) to the end
  220. 'on'
  221. >>> word[-2:] # characters from the second-last (included) to the end
  222. 'on'
  223. One way to remember how slices work is to think of the indices as pointing
  224. *between* characters, with the left edge of the first character numbered 0.
  225. Then the right edge of the last character of a string of *n* characters has
  226. index *n*, for example::
  227. +---+---+---+---+---+---+
  228. | P | y | t | h | o | n |
  229. +---+---+---+---+---+---+
  230. 0 1 2 3 4 5 6
  231. -6 -5 -4 -3 -2 -1
  232. The first row of numbers gives the position of the indices 0...6 in the string;
  233. the second row gives the corresponding negative indices. The slice from *i* to
  234. *j* consists of all characters between the edges labeled *i* and *j*,
  235. respectively.
  236. For non-negative indices, the length of a slice is the difference of the
  237. indices, if both are within bounds. For example, the length of ``word[1:3]`` is
  238. 2.
  239. Attempting to use an index that is too large will result in an error::
  240. >>> word[42] # the word only has 6 characters
  241. Traceback (most recent call last):
  242. File "<stdin>", line 1, in <module>
  243. IndexError: string index out of range
  244. However, out of range slice indexes are handled gracefully when used for
  245. slicing::
  246. >>> word[4:42]
  247. 'on'
  248. >>> word[42:]
  249. ''
  250. Python strings cannot be changed --- they are :term:`immutable`.
  251. Therefore, assigning to an indexed position in the string results in an error::
  252. >>> word[0] = 'J'
  253. Traceback (most recent call last):
  254. File "<stdin>", line 1, in <module>
  255. TypeError: 'str' object does not support item assignment
  256. >>> word[2:] = 'py'
  257. Traceback (most recent call last):
  258. File "<stdin>", line 1, in <module>
  259. TypeError: 'str' object does not support item assignment
  260. If you need a different string, you should create a new one::
  261. >>> 'J' + word[1:]
  262. 'Jython'
  263. >>> word[:2] + 'py'
  264. 'Pypy'
  265. The built-in function :func:`len` returns the length of a string::
  266. >>> s = 'supercalifragilisticexpialidocious'
  267. >>> len(s)
  268. 34
  269. .. seealso::
  270. :ref:`textseq`
  271. Strings are examples of *sequence types*, and support the common
  272. operations supported by such types.
  273. :ref:`string-methods`
  274. Strings support a large number of methods for
  275. basic transformations and searching.
  276. :ref:`f-strings`
  277. String literals that have embedded expressions.
  278. :ref:`formatstrings`
  279. Information about string formatting with :meth:`str.format`.
  280. :ref:`old-string-formatting`
  281. The old formatting operations invoked when strings are
  282. the left operand of the ``%`` operator are described in more detail here.
  283. .. _tut-lists:
  284. Lists
  285. -----
  286. Python knows a number of *compound* data types, used to group together other
  287. values. The most versatile is the *list*, which can be written as a list of
  288. comma-separated values (items) between square brackets. Lists might contain
  289. items of different types, but usually the items all have the same type. ::
  290. >>> squares = [1, 4, 9, 16, 25]
  291. >>> squares
  292. [1, 4, 9, 16, 25]
  293. Like strings (and all other built-in :term:`sequence` type), lists can be
  294. indexed and sliced::
  295. >>> squares[0] # indexing returns the item
  296. 1
  297. >>> squares[-1]
  298. 25
  299. >>> squares[-3:] # slicing returns a new list
  300. [9, 16, 25]
  301. All slice operations return a new list containing the requested elements. This
  302. means that the following slice returns a new (shallow) copy of the list::
  303. >>> squares[:]
  304. [1, 4, 9, 16, 25]
  305. Lists also support operations like concatenation::
  306. >>> squares + [36, 49, 64, 81, 100]
  307. [1, 4, 9, 16, 25, 36, 49, 64, 81, 100]
  308. Unlike strings, which are :term:`immutable`, lists are a :term:`mutable`
  309. type, i.e. it is possible to change their content::
  310. >>> cubes = [1, 8, 27, 65, 125] # something's wrong here
  311. >>> 4 ** 3 # the cube of 4 is 64, not 65!
  312. 64
  313. >>> cubes[3] = 64 # replace the wrong value
  314. >>> cubes
  315. [1, 8, 27, 64, 125]
  316. You can also add new items at the end of the list, by using
  317. the :meth:`~list.append` *method* (we will see more about methods later)::
  318. >>> cubes.append(216) # add the cube of 6
  319. >>> cubes.append(7 ** 3) # and the cube of 7
  320. >>> cubes
  321. [1, 8, 27, 64, 125, 216, 343]
  322. Assignment to slices is also possible, and this can even change the size of the
  323. list or clear it entirely::
  324. >>> letters = ['a', 'b', 'c', 'd', 'e', 'f', 'g']
  325. >>> letters
  326. ['a', 'b', 'c', 'd', 'e', 'f', 'g']
  327. >>> # replace some values
  328. >>> letters[2:5] = ['C', 'D', 'E']
  329. >>> letters
  330. ['a', 'b', 'C', 'D', 'E', 'f', 'g']
  331. >>> # now remove them
  332. >>> letters[2:5] = []
  333. >>> letters
  334. ['a', 'b', 'f', 'g']
  335. >>> # clear the list by replacing all the elements with an empty list
  336. >>> letters[:] = []
  337. >>> letters
  338. []
  339. The built-in function :func:`len` also applies to lists::
  340. >>> letters = ['a', 'b', 'c', 'd']
  341. >>> len(letters)
  342. 4
  343. It is possible to nest lists (create lists containing other lists), for
  344. example::
  345. >>> a = ['a', 'b', 'c']
  346. >>> n = [1, 2, 3]
  347. >>> x = [a, n]
  348. >>> x
  349. [['a', 'b', 'c'], [1, 2, 3]]
  350. >>> x[0]
  351. ['a', 'b', 'c']
  352. >>> x[0][1]
  353. 'b'
  354. .. _tut-firststeps:
  355. First Steps Towards Programming
  356. ===============================
  357. Of course, we can use Python for more complicated tasks than adding two and two
  358. together. For instance, we can write an initial sub-sequence of the
  359. `Fibonacci series <https://en.wikipedia.org/wiki/Fibonacci_number>`_
  360. as follows::
  361. >>> # Fibonacci series:
  362. ... # the sum of two elements defines the next
  363. ... a, b = 0, 1
  364. >>> while a < 10:
  365. ... print(a)
  366. ... a, b = b, a+b
  367. ...
  368. 0
  369. 1
  370. 1
  371. 2
  372. 3
  373. 5
  374. 8
  375. This example introduces several new features.
  376. * The first line contains a *multiple assignment*: the variables ``a`` and ``b``
  377. simultaneously get the new values 0 and 1. On the last line this is used again,
  378. demonstrating that the expressions on the right-hand side are all evaluated
  379. first before any of the assignments take place. The right-hand side expressions
  380. are evaluated from the left to the right.
  381. * The :keyword:`while` loop executes as long as the condition (here: ``a < 10``)
  382. remains true. In Python, like in C, any non-zero integer value is true; zero is
  383. false. The condition may also be a string or list value, in fact any sequence;
  384. anything with a non-zero length is true, empty sequences are false. The test
  385. used in the example is a simple comparison. The standard comparison operators
  386. are written the same as in C: ``<`` (less than), ``>`` (greater than), ``==``
  387. (equal to), ``<=`` (less than or equal to), ``>=`` (greater than or equal to)
  388. and ``!=`` (not equal to).
  389. * The *body* of the loop is *indented*: indentation is Python's way of grouping
  390. statements. At the interactive prompt, you have to type a tab or space(s) for
  391. each indented line. In practice you will prepare more complicated input
  392. for Python with a text editor; all decent text editors have an auto-indent
  393. facility. When a compound statement is entered interactively, it must be
  394. followed by a blank line to indicate completion (since the parser cannot
  395. guess when you have typed the last line). Note that each line within a basic
  396. block must be indented by the same amount.
  397. * The :func:`print` function writes the value of the argument(s) it is given.
  398. It differs from just writing the expression you want to write (as we did
  399. earlier in the calculator examples) in the way it handles multiple arguments,
  400. floating point quantities, and strings. Strings are printed without quotes,
  401. and a space is inserted between items, so you can format things nicely, like
  402. this::
  403. >>> i = 256*256
  404. >>> print('The value of i is', i)
  405. The value of i is 65536
  406. The keyword argument *end* can be used to avoid the newline after the output,
  407. or end the output with a different string::
  408. >>> a, b = 0, 1
  409. >>> while a < 1000:
  410. ... print(a, end=',')
  411. ... a, b = b, a+b
  412. ...
  413. 0,1,1,2,3,5,8,13,21,34,55,89,144,233,377,610,987,
  414. .. rubric:: Footnotes
  415. .. [#] Since ``**`` has higher precedence than ``-``, ``-3**2`` will be
  416. interpreted as ``-(3**2)`` and thus result in ``-9``. To avoid this
  417. and get ``9``, you can use ``(-3)**2``.
  418. .. [#] Unlike other languages, special characters such as ``\n`` have the
  419. same meaning with both single (``'...'``) and double (``"..."``) quotes.
  420. The only difference between the two is that within single quotes you don't
  421. need to escape ``"`` (but you have to escape ``\'``) and vice versa.