Changeset 391 for python/trunk/Doc/library/sys.rst
- Timestamp:
- Mar 19, 2014, 11:31:01 PM (11 years ago)
- Location:
- python/trunk
- Files:
-
- 2 edited
Legend:
- Unmodified
- Added
- Removed
-
python/trunk
-
Property svn:mergeinfo
set to
/python/vendor/Python-2.7.6 merged eligible /python/vendor/current merged eligible
-
Property svn:mergeinfo
set to
-
python/trunk/Doc/library/sys.rst
r2 r391 1 2 1 :mod:`sys` --- System-specific parameters and functions 3 2 ======================================================= … … 33 32 34 33 35 .. data:: subversion36 37 A triple (repo, branch, version) representing the Subversion information of the38 Python interpreter. *repo* is the name of the repository, ``'CPython'``.39 *branch* is a string of one of the forms ``'trunk'``, ``'branches/name'`` or40 ``'tags/name'``. *version* is the output of ``svnversion``, if the interpreter41 was built from a Subversion checkout; it contains the revision number (range)42 and possibly a trailing 'M' if there were local modifications. If the tree was43 exported (or svnversion was not available), it is the revision of44 ``Include/patchlevel.h`` if the branch is a tag. Otherwise, it is ``None``.45 46 .. versionadded:: 2.547 48 49 34 .. data:: builtin_module_names 50 35 … … 52 37 Python interpreter. (This information is not available in any other way --- 53 38 ``modules.keys()`` only lists the imported modules.) 39 40 41 .. function:: call_tracing(func, args) 42 43 Call ``func(*args)``, while tracing is enabled. The tracing state is saved, 44 and restored afterwards. This is intended to be called from a debugger from 45 a checkpoint, to recursively debug some other code. 54 46 55 47 … … 101 93 entered in an interactive Python session. The display of these values can be 102 94 customized by assigning another one-argument function to ``sys.displayhook``. 95 96 97 .. data:: dont_write_bytecode 98 99 If this is true, Python won't try to write ``.pyc`` or ``.pyo`` files on the 100 import of source modules. This value is initially set to ``True`` or 101 ``False`` depending on the :option:`-B` command line option and the 102 :envvar:`PYTHONDONTWRITEBYTECODE` environment variable, but you can set it 103 yourself to control bytecode file generation. 104 105 .. versionadded:: 2.6 103 106 104 107 … … 202 205 A string giving the site-specific directory prefix where the platform-dependent 203 206 Python files are installed; by default, this is also ``'/usr/local'``. This can 204 be set at build time with the :option:`--exec-prefix` argument to the207 be set at build time with the ``--exec-prefix`` argument to the 205 208 :program:`configure` script. Specifically, all configuration files (e.g. the 206 :file:`pyconfig.h` header file) are installed in the directory ``exec_prefix +207 '/lib/pythonversion/config'``, and shared library modules are installed in208 ``exec_prefix + '/lib/pythonversion/lib-dynload'``, where *version* is equal to209 ``version[:3]``.209 :file:`pyconfig.h` header file) are installed in the directory 210 :file:`{exec_prefix}/lib/python{X.Y}/config`, and shared library modules are 211 installed in :file:`{exec_prefix}/lib/python{X.Y}/lib-dynload`, where *X.Y* 212 is the version number of Python, for example ``2.7``. 210 213 211 214 212 215 .. data:: executable 213 216 214 A string giving the name of the executable binary for the Python interpreter, on 215 systems where this makes sense. 217 A string giving the absolute path of the executable binary for the Python 218 interpreter, on systems where this makes sense. If Python is unable to retrieve 219 the real path to its executable, :data:`sys.executable` will be an empty string 220 or ``None``. 216 221 217 222 … … 220 225 Exit from Python. This is implemented by raising the :exc:`SystemExit` 221 226 exception, so cleanup actions specified by finally clauses of :keyword:`try` 222 statements are honored, and it is possible to intercept the exit attempt at an 223 outer level. The optional argument *arg* can be an integer giving the exit 224 status (defaulting to zero), or another type of object. If it is an integer, 225 zero is considered "successful termination" and any nonzero value is considered 226 "abnormal termination" by shells and the like. Most systems require it to be in 227 the range 0-127, and produce undefined results otherwise. Some systems have a 228 convention for assigning specific meanings to specific exit codes, but these are 229 generally underdeveloped; Unix programs generally use 2 for command line syntax 230 errors and 1 for all other kind of errors. If another type of object is passed, 231 ``None`` is equivalent to passing zero, and any other object is printed to 232 ``sys.stderr`` and results in an exit code of 1. In particular, 233 ``sys.exit("some error message")`` is a quick way to exit a program when an 234 error occurs. 227 statements are honored, and it is possible to intercept the exit attempt at 228 an outer level. 229 230 The optional argument *arg* can be an integer giving the exit status 231 (defaulting to zero), or another type of object. If it is an integer, zero 232 is considered "successful termination" and any nonzero value is considered 233 "abnormal termination" by shells and the like. Most systems require it to be 234 in the range 0-127, and produce undefined results otherwise. Some systems 235 have a convention for assigning specific meanings to specific exit codes, but 236 these are generally underdeveloped; Unix programs generally use 2 for command 237 line syntax errors and 1 for all other kind of errors. If another type of 238 object is passed, ``None`` is equivalent to passing zero, and any other 239 object is printed to :data:`stderr` and results in an exit code of 1. In 240 particular, ``sys.exit("some error message")`` is a quick way to exit a 241 program when an error occurs. 242 243 Since :func:`exit` ultimately "only" raises an exception, it will only exit 244 the process when called from the main thread, and the exception is not 245 intercepted. 235 246 236 247 … … 257 268 attributes are read only. 258 269 259 +------------------------------+------------------------------------------+ 260 | attribute | flag | 261 +==============================+==========================================+ 262 | :const:`debug` | -d | 263 +------------------------------+------------------------------------------+ 264 | :const:`py3k_warning` | -3 | 265 +------------------------------+------------------------------------------+ 266 | :const:`division_warning` | -Q | 267 +------------------------------+------------------------------------------+ 268 | :const:`division_new` | -Qnew | 269 +------------------------------+------------------------------------------+ 270 | :const:`inspect` | -i | 271 +------------------------------+------------------------------------------+ 272 | :const:`interactive` | -i | 273 +------------------------------+------------------------------------------+ 274 | :const:`optimize` | -O or -OO | 275 +------------------------------+------------------------------------------+ 276 | :const:`dont_write_bytecode` | -B | 277 +------------------------------+------------------------------------------+ 278 | :const:`no_user_site` | -s | 279 +------------------------------+------------------------------------------+ 280 | :const:`no_site` | -S | 281 +------------------------------+------------------------------------------+ 282 | :const:`ignore_environment` | -E | 283 +------------------------------+------------------------------------------+ 284 | :const:`tabcheck` | -t or -tt | 285 +------------------------------+------------------------------------------+ 286 | :const:`verbose` | -v | 287 +------------------------------+------------------------------------------+ 288 | :const:`unicode` | -U | 289 +------------------------------+------------------------------------------+ 290 | :const:`bytes_warning` | -b | 291 +------------------------------+------------------------------------------+ 270 ============================= =================================== 271 attribute flag 272 ============================= =================================== 273 :const:`debug` :option:`-d` 274 :const:`py3k_warning` :option:`-3` 275 :const:`division_warning` :option:`-Q` 276 :const:`division_new` :option:`-Qnew <-Q>` 277 :const:`inspect` :option:`-i` 278 :const:`interactive` :option:`-i` 279 :const:`optimize` :option:`-O` or :option:`-OO` 280 :const:`dont_write_bytecode` :option:`-B` 281 :const:`no_user_site` :option:`-s` 282 :const:`no_site` :option:`-S` 283 :const:`ignore_environment` :option:`-E` 284 :const:`tabcheck` :option:`-t` or :option:`-tt <-t>` 285 :const:`verbose` :option:`-v` 286 :const:`unicode` :option:`-U` 287 :const:`bytes_warning` :option:`-b` 288 :const:`hash_randomization` :option:`-R` 289 ============================= =================================== 292 290 293 291 .. versionadded:: 2.6 294 292 293 .. versionadded:: 2.7.3 294 The ``hash_randomization`` attribute. 295 295 296 296 .. data:: float_info 297 297 298 298 A structseq holding information about the float type. It contains low level 299 information about the precision and internal representation. Please study 300 your system's :file:`float.h` for more information. 301 302 +---------------------+--------------------------------------------------+ 303 | attribute | explanation | 304 +=====================+==================================================+ 305 | :const:`epsilon` | Difference between 1 and the next representable | 306 | | floating point number | 307 +---------------------+--------------------------------------------------+ 308 | :const:`dig` | digits (see :file:`float.h`) | 309 +---------------------+--------------------------------------------------+ 310 | :const:`mant_dig` | mantissa digits (see :file:`float.h`) | 311 +---------------------+--------------------------------------------------+ 312 | :const:`max` | maximum representable finite float | 313 +---------------------+--------------------------------------------------+ 314 | :const:`max_exp` | maximum int e such that radix**(e-1) is in the | 315 | | range of finite representable floats | 316 +---------------------+--------------------------------------------------+ 317 | :const:`max_10_exp` | maximum int e such that 10**e is in the | 318 | | range of finite representable floats | 319 +---------------------+--------------------------------------------------+ 320 | :const:`min` | Minimum positive normalizer float | 321 +---------------------+--------------------------------------------------+ 322 | :const:`min_exp` | minimum int e such that radix**(e-1) is a | 323 | | normalized float | 324 +---------------------+--------------------------------------------------+ 325 | :const:`min_10_exp` | minimum int e such that 10**e is a normalized | 326 | | float | 327 +---------------------+--------------------------------------------------+ 328 | :const:`radix` | radix of exponent | 329 +---------------------+--------------------------------------------------+ 330 | :const:`rounds` | addition rounds (see :file:`float.h`) | 331 +---------------------+--------------------------------------------------+ 332 333 .. note:: 334 335 The information in the table is simplified. 299 information about the precision and internal representation. The values 300 correspond to the various floating-point constants defined in the standard 301 header file :file:`float.h` for the 'C' programming language; see section 302 5.2.4.2.2 of the 1999 ISO/IEC C standard [C99]_, 'Characteristics of 303 floating types', for details. 304 305 .. tabularcolumns:: |l|l|L| 306 307 +---------------------+----------------+--------------------------------------------------+ 308 | attribute | float.h macro | explanation | 309 +=====================+================+==================================================+ 310 | :const:`epsilon` | DBL_EPSILON | difference between 1 and the least value greater | 311 | | | than 1 that is representable as a float | 312 +---------------------+----------------+--------------------------------------------------+ 313 | :const:`dig` | DBL_DIG | maximum number of decimal digits that can be | 314 | | | faithfully represented in a float; see below | 315 +---------------------+----------------+--------------------------------------------------+ 316 | :const:`mant_dig` | DBL_MANT_DIG | float precision: the number of base-``radix`` | 317 | | | digits in the significand of a float | 318 +---------------------+----------------+--------------------------------------------------+ 319 | :const:`max` | DBL_MAX | maximum representable finite float | 320 +---------------------+----------------+--------------------------------------------------+ 321 | :const:`max_exp` | DBL_MAX_EXP | maximum integer e such that ``radix**(e-1)`` is | 322 | | | a representable finite float | 323 +---------------------+----------------+--------------------------------------------------+ 324 | :const:`max_10_exp` | DBL_MAX_10_EXP | maximum integer e such that ``10**e`` is in the | 325 | | | range of representable finite floats | 326 +---------------------+----------------+--------------------------------------------------+ 327 | :const:`min` | DBL_MIN | minimum positive normalized float | 328 +---------------------+----------------+--------------------------------------------------+ 329 | :const:`min_exp` | DBL_MIN_EXP | minimum integer e such that ``radix**(e-1)`` is | 330 | | | a normalized float | 331 +---------------------+----------------+--------------------------------------------------+ 332 | :const:`min_10_exp` | DBL_MIN_10_EXP | minimum integer e such that ``10**e`` is a | 333 | | | normalized float | 334 +---------------------+----------------+--------------------------------------------------+ 335 | :const:`radix` | FLT_RADIX | radix of exponent representation | 336 +---------------------+----------------+--------------------------------------------------+ 337 | :const:`rounds` | FLT_ROUNDS | integer constant representing the rounding mode | 338 | | | used for arithmetic operations. This reflects | 339 | | | the value of the system FLT_ROUNDS macro at | 340 | | | interpreter startup time. See section 5.2.4.2.2 | 341 | | | of the C99 standard for an explanation of the | 342 | | | possible values and their meanings. | 343 +---------------------+----------------+--------------------------------------------------+ 344 345 The attribute :attr:`sys.float_info.dig` needs further explanation. If 346 ``s`` is any string representing a decimal number with at most 347 :attr:`sys.float_info.dig` significant digits, then converting ``s`` to a 348 float and back again will recover a string representing the same decimal 349 value:: 350 351 >>> import sys 352 >>> sys.float_info.dig 353 15 354 >>> s = '3.14159265358979' # decimal string with 15 significant digits 355 >>> format(float(s), '.15g') # convert to float and back -> same value 356 '3.14159265358979' 357 358 But for strings with more than :attr:`sys.float_info.dig` significant digits, 359 this isn't always true:: 360 361 >>> s = '9876543211234567' # 16 significant digits is too many! 362 >>> format(float(s), '.16g') # conversion changes value 363 '9876543211234568' 336 364 337 365 .. versionadded:: 2.6 366 367 .. data:: float_repr_style 368 369 A string indicating how the :func:`repr` function behaves for 370 floats. If the string has value ``'short'`` then for a finite 371 float ``x``, ``repr(x)`` aims to produce a short string with the 372 property that ``float(repr(x)) == x``. This is the usual behaviour 373 in Python 2.7 and later. Otherwise, ``float_repr_style`` has value 374 ``'legacy'`` and ``repr(x)`` behaves in the same way as it did in 375 versions of Python prior to 2.7. 376 377 .. versionadded:: 2.7 338 378 339 379 … … 355 395 .. function:: getdlopenflags() 356 396 357 Return the current value of the flags that are used for :c func:`dlopen` calls.397 Return the current value of the flags that are used for :c:func:`dlopen` calls. 358 398 The flag constants are defined in the :mod:`dl` and :mod:`DLFCN` modules. 359 399 Availability: Unix. … … 368 408 depends on the operating system: 369 409 370 * On Windows 9x, the encoding is "mbcs". 371 372 * On Mac OS X, the encoding is "utf-8". 410 * On Mac OS X, the encoding is ``'utf-8'``. 373 411 374 412 * On Unix, the encoding is the user's preference according to the result of 375 nl_langinfo(CODESET), or :const:`None` if the ``nl_langinfo(CODESET)`` failed. 413 nl_langinfo(CODESET), or ``None`` if the ``nl_langinfo(CODESET)`` 414 failed. 376 415 377 416 * On Windows NT+, file names are Unicode natively, so no conversion is 378 performed. :func:`getfilesystemencoding` still returns ``'mbcs'``, as this is 379 the encoding that applications should use when they explicitly want to convert 380 Unicode strings to byte strings that are equivalent when used as file names. 417 performed. :func:`getfilesystemencoding` still returns ``'mbcs'``, as 418 this is the encoding that applications should use when they explicitly 419 want to convert Unicode strings to byte strings that are equivalent when 420 used as file names. 421 422 * On Windows 9x, the encoding is ``'mbcs'``. 381 423 382 424 .. versionadded:: 2.3 … … 406 448 407 449 If given, *default* will be returned if the object does not provide means to 408 retrieve the size. Otherwise a `TypeError` will be raised.450 retrieve the size. Otherwise a :exc:`TypeError` will be raised. 409 451 410 452 :func:`getsizeof` calls the object's ``__sizeof__`` method and adds an … … 459 501 .. function:: getwindowsversion() 460 502 461 Return a tuple containing five components, describing the Windows version 462 currently running. The elements are *major*, *minor*, *build*, *platform*, and 463 *text*. *text* contains a string while all other values are integers. 503 Return a named tuple describing the Windows version 504 currently running. The named elements are *major*, *minor*, 505 *build*, *platform*, *service_pack*, *service_pack_minor*, 506 *service_pack_major*, *suite_mask*, and *product_type*. 507 *service_pack* contains a string while all other values are 508 integers. The components can also be accessed by name, so 509 ``sys.getwindowsversion()[0]`` is equivalent to 510 ``sys.getwindowsversion().major``. For compatibility with prior 511 versions, only the first 5 elements are retrievable by indexing. 464 512 465 513 *platform* may be one of the following values: … … 477 525 +-----------------------------------------+-------------------------+ 478 526 479 This function wraps the Win32 :cfunc:`GetVersionEx` function; see the Microsoft 480 documentation for more information about these fields. 527 *product_type* may be one of the following values: 528 529 +---------------------------------------+---------------------------------+ 530 | Constant | Meaning | 531 +=======================================+=================================+ 532 | :const:`1 (VER_NT_WORKSTATION)` | The system is a workstation. | 533 +---------------------------------------+---------------------------------+ 534 | :const:`2 (VER_NT_DOMAIN_CONTROLLER)` | The system is a domain | 535 | | controller. | 536 +---------------------------------------+---------------------------------+ 537 | :const:`3 (VER_NT_SERVER)` | The system is a server, but not | 538 | | a domain controller. | 539 +---------------------------------------+---------------------------------+ 540 541 542 This function wraps the Win32 :c:func:`GetVersionEx` function; see the 543 Microsoft documentation on :c:func:`OSVERSIONINFOEX` for more information 544 about these fields. 481 545 482 546 Availability: Windows. 483 547 484 548 .. versionadded:: 2.3 549 .. versionchanged:: 2.7 550 Changed to a named tuple and added *service_pack_minor*, 551 *service_pack_major*, *suite_mask*, and *product_type*. 485 552 486 553 … … 503 570 same information. 504 571 572 The ``hexversion`` is a 32-bit number with the following layout: 573 574 +-------------------------+------------------------------------------------+ 575 | Bits (big endian order) | Meaning | 576 +=========================+================================================+ 577 | :const:`1-8` | ``PY_MAJOR_VERSION`` (the ``2`` in | 578 | | ``2.1.0a3``) | 579 +-------------------------+------------------------------------------------+ 580 | :const:`9-16` | ``PY_MINOR_VERSION`` (the ``1`` in | 581 | | ``2.1.0a3``) | 582 +-------------------------+------------------------------------------------+ 583 | :const:`17-24` | ``PY_MICRO_VERSION`` (the ``0`` in | 584 | | ``2.1.0a3``) | 585 +-------------------------+------------------------------------------------+ 586 | :const:`25-28` | ``PY_RELEASE_LEVEL`` (``0xA`` for alpha, | 587 | | ``0xB`` for beta, ``0xC`` for release | 588 | | candidate and ``0xF`` for final) | 589 +-------------------------+------------------------------------------------+ 590 | :const:`29-32` | ``PY_RELEASE_SERIAL`` (the ``3`` in | 591 | | ``2.1.0a3``, zero for final releases) | 592 +-------------------------+------------------------------------------------+ 593 594 Thus ``2.1.0a3`` is hexversion ``0x020100a3``. 595 505 596 .. versionadded:: 1.5.2 597 598 599 .. data:: long_info 600 601 A struct sequence that holds information about Python's 602 internal representation of integers. The attributes are read only. 603 604 .. tabularcolumns:: |l|L| 605 606 +-------------------------+----------------------------------------------+ 607 | Attribute | Explanation | 608 +=========================+==============================================+ 609 | :const:`bits_per_digit` | number of bits held in each digit. Python | 610 | | integers are stored internally in base | 611 | | ``2**long_info.bits_per_digit`` | 612 +-------------------------+----------------------------------------------+ 613 | :const:`sizeof_digit` | size in bytes of the C type used to | 614 | | represent a digit | 615 +-------------------------+----------------------------------------------+ 616 617 .. versionadded:: 2.7 506 618 507 619 … … 550 662 absolute name of the module being imported. If the module to be imported is 551 663 contained in package then the parent package's :attr:`__path__` attribute 552 is passed in as a second argument. The method returns :keyword:`None` if664 is passed in as a second argument. The method returns ``None`` if 553 665 the module cannot be found, else returns a :term:`loader`. 554 666 … … 609 721 paths that have been passed to :data:`sys.path_hooks` and the values are 610 722 the finders that are found. If a path is a valid file system path but no 611 explicit finder is found on :data:`sys.path_hooks` then :keyword:`None` is723 explicit finder is found on :data:`sys.path_hooks` then ``None`` is 612 724 stored to represent the implicit default finder should be used. If the path 613 725 is not an existing path then :class:`imp.NullImporter` is set. … … 621 733 platform-specific components to :data:`sys.path`, for instance. 622 734 623 For Unix systems, this is the lowercased OS name as returned by ``uname -s`` 624 with the first part of the version as returned by ``uname -r`` appended, 625 e.g. ``'sunos5'`` or ``'linux2'``, *at the time when Python was built*. 735 For most Unix systems, this is the lowercased OS name as returned by ``uname 736 -s`` with the first part of the version as returned by ``uname -r`` appended, 737 e.g. ``'sunos5'``, *at the time when Python was built*. Unless you want to 738 test for a specific system version, it is therefore recommended to use the 739 following idiom:: 740 741 if sys.platform.startswith('freebsd'): 742 # FreeBSD-specific code here... 743 elif sys.platform.startswith('linux'): 744 # Linux-specific code here... 745 746 .. versionchanged:: 2.7.3 747 Since lots of code check for ``sys.platform == 'linux2'``, and there is 748 no essential change between Linux 2.x and 3.x, ``sys.platform`` is always 749 set to ``'linux2'``, even on Linux 3.x. In Python 3.3 and later, the 750 value will always be set to ``'linux'``, so it is recommended to always 751 use the ``startswith`` idiom presented above. 752 626 753 For other systems, the values are: 627 754 628 ================ =========================== 629 System :data:`platform` value 630 ================ =========================== 631 Windows ``'win32'`` 632 Windows/Cygwin ``'cygwin'`` 633 Mac OS X ``'darwin'`` 634 OS/2 ``'os2'`` 635 OS/2 EMX ``'os2emx'`` 636 RiscOS ``'riscos'`` 637 AtheOS ``'atheos'`` 638 ================ =========================== 639 755 ===================== =========================== 756 System :data:`platform` value 757 ===================== =========================== 758 Linux (2.x *and* 3.x) ``'linux2'`` 759 Windows ``'win32'`` 760 Windows/Cygwin ``'cygwin'`` 761 Mac OS X ``'darwin'`` 762 OS/2 ``'os2'`` 763 OS/2 EMX ``'os2emx'`` 764 RiscOS ``'riscos'`` 765 AtheOS ``'atheos'`` 766 ===================== =========================== 767 768 .. seealso:: 769 :attr:`os.name` has a coarser granularity. :func:`os.uname` gives 770 system-dependent version information. 771 772 The :mod:`platform` module provides detailed checks for the 773 system's identity. 640 774 641 775 .. data:: prefix … … 643 777 A string giving the site-specific directory prefix where the platform 644 778 independent Python files are installed; by default, this is the string 645 ``'/usr/local'``. This can be set at build time with the :option:`--prefix`779 ``'/usr/local'``. This can be set at build time with the ``--prefix`` 646 780 argument to the :program:`configure` script. The main collection of Python 647 library modules is installed in the directory ``prefix + '/lib/pythonversion'``781 library modules is installed in the directory :file:`{prefix}/lib/python{X.Y}` 648 782 while the platform independent header files (all except :file:`pyconfig.h`) are 649 stored in ``prefix + '/include/pythonversion'``, where *version* is equal to650 ``version[:3]``.783 stored in :file:`{prefix}/include/python{X.Y}`, where *X.Y* is the version 784 number of Python, for example ``2.7``. 651 785 652 786 … … 668 802 .. data:: py3kwarning 669 803 670 Bool containing the status of the Python 3 .0warning flag. It's ``True``804 Bool containing the status of the Python 3 warning flag. It's ``True`` 671 805 when Python is started with the -3 option. (This should be considered 672 806 read-only; setting it to a different value doesn't have an effect on 673 Python 3.0 warnings.) 674 675 .. versionadded:: 2.6 676 677 678 .. data:: dont_write_bytecode 679 680 If this is true, Python won't try to write ``.pyc`` or ``.pyo`` files on the 681 import of source modules. This value is initially set to ``True`` or ``False`` 682 depending on the ``-B`` command line option and the ``PYTHONDONTWRITEBYTECODE`` 683 environment variable, but you can set it yourself to control bytecode file 684 generation. 807 Python 3 warnings.) 685 808 686 809 .. versionadded:: 2.6 … … 713 836 .. function:: setdlopenflags(n) 714 837 715 Set the flags used by the interpreter for :c func:`dlopen` calls, such as when838 Set the flags used by the interpreter for :c:func:`dlopen` calls, such as when 716 839 the interpreter loads extension modules. Among other things, this will enable a 717 840 lazy resolving of symbols when importing a module, if called as … … 787 910 788 911 ``'line'`` 789 The interpreter is about to execute a new line of code (sometimes multiple 790 line events on one line exist). The local trace function is called; *arg* 791 is ``None``; the return value specifies the new local trace function. 912 The interpreter is about to execute a new line of code or re-execute the 913 condition of a loop. The local trace function is called; *arg* is 914 ``None``; the return value specifies the new local trace function. See 915 :file:`Objects/lnotab_notes.txt` for a detailed explanation of how this 916 works. 792 917 793 918 ``'return'`` 794 919 A function (or other code block) is about to return. The local trace 795 function is called; *arg* is the value that will be returned. The trace 796 function's return value is ignored. 920 function is called; *arg* is the value that will be returned, or ``None`` 921 if the event is caused by an exception being raised. The trace function's 922 return value is ignored. 797 923 798 924 ``'exception'`` … … 806 932 807 933 ``'c_return'`` 808 A C function has returned. *arg* is ``None``.934 A C function has returned. *arg* is the C function object. 809 935 810 936 ``'c_exception'`` 811 A C function has thrown an exception. *arg* is ``None``.937 A C function has raised an exception. *arg* is the C function object. 812 938 813 939 Note that as an exception is propagated down the chain of callers, an … … 828 954 Activate dumping of VM measurements using the Pentium timestamp counter, if 829 955 *on_flag* is true. Deactivate these dumps if *on_flag* is off. The function is 830 available only if Python was compiled with :option:`--with-tsc`. To understand956 available only if Python was compiled with ``--with-tsc``. To understand 831 957 the output of this dump, read :file:`Python/ceval.c` in the Python sources. 832 958 833 959 .. versionadded:: 2.4 960 961 .. impl-detail:: 962 963 This function is intimately bound to CPython implementation details and 964 thus not likely to be implemented elsewhere. 834 965 835 966 … … 870 1001 871 1002 1003 .. data:: subversion 1004 1005 A triple (repo, branch, version) representing the Subversion information of the 1006 Python interpreter. *repo* is the name of the repository, ``'CPython'``. 1007 *branch* is a string of one of the forms ``'trunk'``, ``'branches/name'`` or 1008 ``'tags/name'``. *version* is the output of ``svnversion``, if the interpreter 1009 was built from a Subversion checkout; it contains the revision number (range) 1010 and possibly a trailing 'M' if there were local modifications. If the tree was 1011 exported (or svnversion was not available), it is the revision of 1012 ``Include/patchlevel.h`` if the branch is a tag. Otherwise, it is ``None``. 1013 1014 .. versionadded:: 2.5 1015 1016 .. note:: 1017 Python is now `developed <http://docs.python.org/devguide/>`_ using 1018 Mercurial. In recent Python 2.7 bugfix releases, :data:`subversion` 1019 therefore contains placeholder information. It is removed in Python 1020 3.3. 1021 1022 872 1023 .. data:: tracebacklimit 873 1024 … … 881 1032 882 1033 A string containing the version number of the Python interpreter plus additional 883 information on the build number and compiler used. It has a value of the form 884 ``'version (#build_number, build_date, build_time) [compiler]'``. The first 885 three characters are used to identify the version in the installation 886 directories (where appropriate on each platform). An example:: 887 888 >>> import sys 889 >>> sys.version 890 '1.5.2 (#0 Apr 13 1999, 10:51:12) [MSC 32 bit (Intel)]' 1034 information on the build number and compiler used. This string is displayed 1035 when the interactive interpreter is started. Do not extract version information 1036 out of it, rather, use :data:`version_info` and the functions provided by the 1037 :mod:`platform` module. 891 1038 892 1039 … … 905 1052 integers; the release level is ``'alpha'``, ``'beta'``, ``'candidate'``, or 906 1053 ``'final'``. The ``version_info`` value corresponding to the Python version 2.0 907 is ``(2, 0, 0, 'final', 0)``. 1054 is ``(2, 0, 0, 'final', 0)``. The components can also be accessed by name, 1055 so ``sys.version_info[0]`` is equivalent to ``sys.version_info.major`` 1056 and so on. 908 1057 909 1058 .. versionadded:: 2.0 1059 .. versionchanged:: 2.7 1060 Added named component attributes 910 1061 911 1062 … … 924 1075 module for informational purposes; modifying this value has no effect on the 925 1076 registry keys used by Python. Availability: Windows. 1077 1078 .. rubric:: Citations 1079 1080 .. [C99] ISO/IEC 9899:1999. "Programming languages -- C." A public draft of this standard is available at http://www.open-std.org/jtc1/sc22/wg14/www/docs/n1256.pdf . 1081
Note:
See TracChangeset
for help on using the changeset viewer.