TOCPython Draft for Information Only
ContentPython Built-in Constant
Python Built-in ConstantThere are some keywords are used as Python constants in the built-in namespace.Built-in ConstantsThe list of built-in constants are None, False, True and __debug__. These built-in constants cannot be reassigned. Any assignments to them, even as an attribute name, raise SyntaxError, so they can be considered “true” constants. FalseThe false value of the bool type. Assignments to False are illegal and raise a SyntaxError. TrueThe true value of the bool type. Assignments to True are illegal and raise a SyntaxError. NoneThe sole value of the type NoneType. None is frequently used to represent the absence of a value, as when default arguments are not passed to a function. Assignments to None are illegal and raise a SyntaxError. NotImplemented Special value which should be returned by the binary special methods (e.g. __eq__(), __lt__(), __add__(), __rsub__(), etc.) to indicate that the operation is not implemented with respect to the other type; may be returned by the in-place binary special methods (e.g. __imul__(), __iand__(), etc.) for the same purpose. Its truth value is true. Note When a binary (or in-place) method returns NotImplemented the interpreter will try the reflected operation on the other type (or some other fallback, depending on the operator). If all attempts return NotImplemented, the interpreter will raise an appropriate exception. Incorrectly returning NotImplemented will result in a misleading error message or the NotImplemented value being returned to Python code. See Implementing the arithmetic operations for examples. Note NotImplementedError and NotImplemented are not interchangeable, even though they have similar names and purposes. See NotImplementedError for details on when to use it. EllipsisThe same as the ellipsis literal “...”. Special value used mostly in conjunction with extended slicing syntax for user-defined container data types. __debug__This constant is true if Python was not started with an -O option. See also the assert statement. NoteConstants added by the site moduleThe site module (which is imported automatically during startup, except if the -S command-line option is given) adds several constants to the built-in namespace. They are useful for the interactive interpreter shell and should not be used in programs. quit(code=None) exit(code=None)Objects that when printed, print a message like “Use quit() or Ctrl-D (i.e. EOF) to exit”, and when called, raise SystemExit with the specified exit code. copyright creditsObjects that when printed or called, print the text of copyright or credits, respectively. licenseObject that when printed, prints the message “Type license() to see the full license text”, and when called, displays the full license text in a pager-like fashion (one screen at a time).Source and Reference©sideway ID: 210200006 Last Updated: 2/6/2021 Revision: 0 Latest Updated Links
|
Home 5 Business Management HBR 3 Information Recreation Hobbies 8 Culture Chinese 1097 English 339 Reference 79 Computer Hardware 249 Software Application 213 Digitization 32 Latex 52 Manim 205 KB 1 Numeric 19 Programming Web 289 Unicode 504 HTML 66 CSS 65 SVG 46 ASP.NET 270 OS 429 DeskTop 7 Python 72 Knowledge Mathematics Formulas 8 Set 1 Logic 1 Algebra 84 Number Theory 206 Trigonometry 31 Geometry 34 Calculus 67 Engineering Tables 8 Mechanical Rigid Bodies Statics 92 Dynamics 37 Fluid 5 Control Acoustics 19 Natural Sciences Matter 1 Electric 27 Biology 1 |
Copyright © 2000-2024 Sideway . All rights reserved Disclaimers last modified on 06 September 2019