Notice: While JavaScript is not essential for this website, your interaction with the content will be limited. Please turn JavaScript on for the full experience.
...constants PEP:295 Title:Interpretation of multiline string constants Author:yozh at mx1.ru (Stepan Koltsov) Status:Rejected Type:Standards Track Created:22-Jul-2002 Python-Version:3.0 Post-History: Contents Abstract Rationale Implementation Alternatives Copyright Abstract This PEP describes an interpretation of multiline string constants for Python. It suggests stripping spaces after newlines and stripping a newline if it is first character after an opening quotation. Ra...
...CONSTANT: SUITE of CONSTANT: SUITE else: SUITE case EXPR: if CONSTANT: SUITE if CONSTANT: SUITE else: SUITE when EXPR: in CONSTANT_TUPLE: SUITE in CONSTANT_TUPLE: SUITE ... else: SUITE The switch statement could be extended to allow multiple values for one section (e.g. case 'a', 'b', 'c': ...). Another proposed extension would allow ranges of values (e.g. case 10..14: ...). These should prob...
PEP 681 -- Data Class Transforms PEP:681 Title:Data Class Transforms Author:Erik De Bonte <erikd at microsoft.com>, Eric Traut <erictr at microsoft.com> Sponsor:Jelle Zijlstra <jelle.zijlstra at gmail.com> Discussions-To:https://mail.python.org/archives/list/typing-sig@python.org/thread/EAALIHA3XEDFDNG2NRXTI3ERFPAD65Z4/ Status:Draft Type:Standards Track Created:02-Dec-2021 Python-Version:3.11 Post-History: Contents Abstract Motivation Rationale Specificatio...
...Constants in the Standard Library PEP:329 Title:Treating Builtins as Constants in the Standard Library Author:Raymond Hettinger <python at rcn.com> Status:Rejected Type:Standards Track Created:18-Apr-2004 Python-Version:2.4 Post-History:18-Apr-2004 Contents Abstract Status Motivation Proposal Questions and Answers Sample Implementation References Copyright Abstract The proposal is to add a function for treating builtin references as constants and to apply that functio...
...constants. However, the first expression generates an error on current Python interpreters. A possible alternative is to use: PosInf = 1e300000 NaN = PosInf/PosInf While this does not generate an error with current Python interpreters, it is still an ugly and potentially non-portable hack. In addition, defining NaN in this way does solve the problem of detecting such values. First, the IEEE 754 standard provides for an entire set of constant values for Not-a-Number. Second, the standard re...
...constants" we force programmers to give up good habits. Named constants are introduced in most languages to solve the problem of "magic numbers" occurring in the source code. For example, sys.maxint is a lot more readable than 2147483647. Raymond proposes to use string literals instead of named "enums", observing that the string literal's content can be the name that the constant would otherwise have. Thus, we could write "case 'IGNORECASE':" instead of "case re.IGNORECASE:". However, if the...
...constant_pattern) ':' or_pattern | '**' capture_pattern Mapping pattern is a generalization of iterable unpacking to mappings. Its syntax is similar to dictionary display but each key and value are patterns "{" (pattern ":" pattern)+ "}". A **rest pattern is also allowed, to extract the remaining items. Only literal and constant value patterns are allowed in key positions: import constants match config: case {"route": route}: process_route(route) case {constants.DEFAULT_P...
...constants, and internal constants. User-code facing constants like os.SEEK_*, socket module constants, decimal rounding modes and HTML error codes could require backwards compatibility since user code may expect integers. IntEnum as described above provides the required semantics; being a subclass of int, it does not affect user code that expects integers, while on the other hand allowing printable representations for enumeration values: >>> import socket >>> family = socket....
...constant would be very close to introducing a new Missing value-level constant at runtime, creating a second null-like runtime value in addition to None. Having two different null-like constants in Python (None and Missing) would be confusing. Many newcomers to JavaScript already have difficulty distinguishing between its analogous constants null and undefined. Replace Optional with Nullable. Repurpose Optional to mean “optional item”. Optional[] is too ubiquitous to deprecate, although use o...
...constant values and appending tokens to an output list. Most of the comparisons are with constants imported from the sre_constants module. This means there are lots of LOAD_GLOBAL bytecodes in the compiled output of this module. Just by reading the code it's apparent that the author intended LITERAL, NOT_LITERAL, OPCODES and many other symbols to be constants. Still, each time they are involved in an expression, they must be looked up anew. Most global accesses are actually to objects that ar...
...constants See also optimizations implemented in fatoptimizer, a static optimizer for Python 3.6. The following issues can be implemented with an AST optimizer: Issue #1346238: A constant folding optimization pass for the AST Issue #2181: optimize out local variables at end of function Issue #2499: Fold unary + and not on constants Issue #4264: Patch: optimize code to use LIST_APPEND instead of calling list.append Issue #7682: Optimisation of if with constant expression Issue #10399: AST Optimi...
...constants they are replacing -- specifically, str(replacement_enum_member) == str(original_constant) should be true (and the same for format()). IntEnum, IntFlag, and StrEnum should be as close to a drop-in replacement of existing integer and string constants as is possible. Towards that goal, the str() output of each should be its inherent value; e.g. if Color is an IntEnum: >>> Color.RED <Color.RED: 1> >>> str(Color.RED) '1' >>> format(Color.RED) '1' Note th...
...constants and enums Going to the cloud: Mappings Matching builtin classes Appendix A -- Quick Intro Copyright Abstract This PEP is a tutorial for the pattern matching introduced by PEP 634. PEP 622 proposed syntax for pattern matching, which received detailed discussion both from the community and the Steering Council. A frequent concern was about how easy it would be to explain (and learn) this feature. This PEP addresses that concern providing the kind of document which developers could u...
...constants "false" and "true", in all lowercase. For Python, I prefer to stick with the example set by the existing built-in constants, which all use CapitalizedWords: None, Ellipsis, NotImplemented (as well as all built-in exceptions). Python's built-in namespace uses all lowercase for functions and types only. It has been suggested that, in order to satisfy user expectations, for every x that is considered true in a Boolean context, the expression x == True should be true, and likewise if x ...
...Constant Description 1 MODE_ECB Electronic Code Book 2 MODE_CBC Cipher Block Chaining 3 MODE_CFB Cipher Feedback 5 MODE_OFB Output Feedback 6 MODE_CTR Counter These modes are to be implemented as described in NIST publication SP 800-38A [1]. Descriptions of the first three feedback modes can also be found in Bruce Schneier's book Applied Cryptography [2]. (The numeric value 4 is reserved for MODE_PGP, a variant of CFB described in RFC 2440: "OpenPGP Message Format". This mode isn't co...
Version: None
Released: Oct. 5, 2021
This is an early developer preview of Python 3.11 Major new features of the 3.11 series, compared to 3.10 Python 3.11 is still in development. This release, 3.11.0a1 is the first of seven planned alpha releases. Alpha releases are intended to make it easier to test the current state of …
Released: Nov. 5, 2021
This is an early developer preview of Python 3.11 Major new features of the 3.11 series, compared to 3.10 Python 3.11 is still in development. This release, 3.11.0a2 is the second of seven planned alpha releases. Alpha releases are intended to make it easier to test the current state of …
...constants. A proposed rule to use a leading dot (e.g. .CONSTANT) for that purpose was criticised because it was felt that the dot would not be a visible-enough marker for that purpose. Partly inspired by forms found in other programming languages, a number of different markers/sigils were proposed (such as ^CONSTANT, $CONSTANT, ==CONSTANT, CONSTANT?, or the word enclosed in backticks), although there was no obvious or natural choice. The current proposal therefore leaves the discussion and pos...
...constants": they aren't really immutable, since anyone can still assign to the name. There are existing idioms for avoiding mutable default values. The potential of optimizing code using frozendict in PyPy is unsure; a lot of other things would have to change first. The same holds for compile-time lookups in general. Multiple threads can agree by convention not to mutate a shared dict, there's no great need for enforcement. Multiple processes can't share dicts. Adding a security sandbox writte...
Released: Oct. 2, 2023
This is the sixth maintenance release of Python 3.11 Python 3.11.6 is the newest major release of the Python programming language, and it contains many new features and optimizations. Major new features of the 3.11 series, compared to 3.10 Some of the new major new features and changes in Python …
View Release Notes