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.
...enumerated a bunch of other uses on the python-dev thread. Future Directions Here are a number of future directions to consider. Any adoption of these ideas would require a new PEP, which referenced this one, and would have to be targeted at a Python version subsequent to the 2.1 release. A previous version of this PEP allowed for both setter and getter of attributes on unbound methods, and only getter on bound methods. A number of problems were discovered with this policy. Because method ...
...enumerate" The list_all() function provides the list of all interpreters. In the threading module, which partly inspired the proposed API, the function is called enumerate(). The name is different here to avoid confusing Python users that are not already familiar with the threading API. For them "enumerate" is rather unclear, whereas "list_all" is clear. Alternate solutions to prevent leaking exceptions across interpreters In function calls, uncaught exceptions propagate to the calling frame...
...enumerated type can be used to gate TLS versions. Forward-looking applications should almost never set a maximum TLS version unless they absolutely must, as a TLS backend that is newer than the Python that uses it may support TLS versions that are not in this enumerated type. Additionally, this enumerated type defines two additional flags that can always be used to request either the lowest or highest TLS version supported by an implementation. class TLSVersion(Enum): MINIMUM_SUPPORTED = au...
...enumerate(initializer): new[i] = c return new The .__repr__() method returns a string that can be evaluated to generate a new bytes object containing a bytes literal: >>> bytes([10, 20, 30]) b'\n\x14\x1e' The object has a .decode() method equivalent to the .decode() method of the str object. The object has a classmethod .fromhex() that takes a string of characters from the set [0-9a-fA-F ] and returns a bytes object (similar to binascii.unhexlify). For example: >>...
PEP 636 -- Structural Pattern Matching: Tutorial PEP:636 Title:Structural Pattern Matching: Tutorial Author:Daniel F Moisset <dfmoisset at gmail.com> Sponsor:Guido van Rossum <guido at python.org> BDFL-Delegate: Discussions-To:python-dev at python.org Status:Final Type:Informational Created:12-Sep-2020 Python-Version:3.10 Post-History:22-Oct-2020, 08-Feb-2021 Resolution:https://mail.python.org/archives/list/python-committers@python.org/message/SQC2FTLFV5A7DV7RCEAR2I2...
...enumerated in no particular order. """ def find_distribution (self, path): """find_file(path:string) : Distribution Search and return the distribution containing the file 'path'. Returns None if the file doesn't belong to any distribution that the InstallationDatabase knows about. XXX should this work for directories? """ class Distribution: """Instance attributes: name : string Distribution name files : {string : (s...
...enumerate() - an iterator taking a sequence returning tuples of (index, item). This solves the old "for i in range(len(seq))" problem more elegantly. (PEP 279) basestring - an abstract string type which is the base class for str (8-bit strings) and unicode. Primarily used to simplify tests for string-ness to isinstance(x, basestring). bool, True, False - these were introduced as ints in Python 2.2.1, but are now a separate type (a subtype of int). This means that True and False are...
...enumerate() function which was accepted for Python 2.3. Also, the proposal both allowed and encouraged misuses such as: >>> for i in 3: print i 0 1 2 Likewise, it was not helpful that the proposal would disable the syntax error in statements like: x, = 1 Specification Define an iterator for types.intType (i.e., the builtin type "int") that is returned from the builtin function "iter" when called with an instance of types.intType as the argument. The returned iterator has the follo...
...enumerate the tests, marking them as 'to be run' in a database, and then copy the build to shared directories on a manually listed set of 'slave' machines. Forcing developers to manually specify which machines to use was initially created as the 'simplest thing that could possibly work.' Contrary to our expectations, we have since had little motivation to automate this. It turns out that negotiation between developers over which machines to use during builds is a valuable excuse to touch base wi...
...enumerate($VARS): $VAR = getattr($value, $attrs[i]) except AttributeError: FAIL Example: [6] Class patterns with all keyword patterns: case ClsName($KEYWORD_PATTERNS): translates to: if not isinstance($value, ClsName): FAIL try: for $KEYWORD in $KEYWORD_PATTERNS: $tmp = getattr($value, QUOTE($KEYWORD)) $KEYWORD_PATTERNS[$KEYWORD] = $tmp except AttributeError: FAIL Example: [7] Class patterns with positional and keyword patterns: case ClsName($VARS, $...
PEP 316 -- Programming by Contract for Python PEP:316 Title:Programming by Contract for Python Author:Terence Way <terry at wayforward.net> Status:Deferred Type:Standards Track Created:02-May-2003 Post-History: Contents Abstract Motivation Specification Exceptions Inheritance Rationale Reference Implementation References Copyright Abstract This submission describes programming by contract for Python. Eiffel's Design By Contract(tm) is perhaps the most popular use of ...
...enumerate() or zip() built-in functions, a common theme is that if a beginner finds themselves manually indexing or slicing a string, then they should consider whether there is a higher-level method that better communicates what the code should do rather than merely how the code should do it. The proposed removeprefix() and removesuffix() methods expand the high-level string "toolbox" and further allow for this sort of skepticism toward manual slicing. The main opportunity for user confusion w...
...enumerate the installed Python versions and use the latest minor release found for the major version, which is likely, although not guaranteed, to be the most recently installed version in that family. In addition to environment variables, the same settings can be configured in the .INI file used by the launcher. The section in the INI file is called [defaults] and the key name will be the same as the environment variables without the leading PY_ prefix (and note that the key names in the INI f...
...enumerate(newconsts): if o is cls: c_pos = pos if o is __super__: s_pos = pos if o == name: n_pos = pos # Add in any missing objects to constants and varnames if c_pos is None: c_pos = len(newconsts) newconsts.append(cls) if n_pos is None: n_pos = len(newconsts) newconsts.append(name) if s_pos is None: s_pos = len(newconsts) newconsts.append(__super__) if sv_pos i...
...enumerates the registry and displays the available Company-Tag pairs that could be used to launch an environment and the target executable. It only shows the most-preferred target for the tag. Backwards-compatible handling of PythonCore is omitted but shown in a later example: # Display most-preferred environments. # Assumes a 64-bit operating system # Does not correctly handle PythonCore compatibility import winreg def enum_keys(key): i = 0 while True: try: yield ...
PEP 657 -- Include Fine Grained Error Locations in Tracebacks PEP:657 Title:Include Fine Grained Error Locations in Tracebacks Author:Pablo Galindo <pablogsal at python.org>, Batuhan Taskaya <batuhan at python.org>, Ammar Askar <ammar at ammaraskar.com> Discussions-To:https://discuss.python.org/t/pep-657-include-fine-grained-error-locations-in-tracebacks/8629 Status:Final Type:Standards Track Created:08-May-2021 Python-Version:3.11 Post-History: Contents Abs...
...enumerate(self._variable_names) } return self._name_to_offset_mapping_impl class FrameType: _fast_locals : array[Object] # The values of the local variables, items may be NULL. _locals: dict | NULL # Dictionary returned by PyEval_GetLocals() def __init__(self, ...): self._locals = NULL ... @property def f_locals(self): return FastLocalsProxy(self) class FastLocalsProxy: __slots__ "_frame" def __init__(self, frame:Fram...
PEP 520 -- Preserving Class Attribute Definition Order PEP:520 Title:Preserving Class Attribute Definition Order Author:Eric Snow <ericsnowcurrently at gmail.com> Status:Final Type:Standards Track Created:07-Jun-2016 Python-Version:3.6 Post-History:07-Jun-2016, 11-Jun-2016, 20-Jun-2016, 24-Jun-2016 Resolution:https://mail.python.org/pipermail/python-dev/2016-June/145442.html Contents Abstract Motivation Background Specification Why a tuple? Why not a read-only attribute...
...enumerate all available clocks, allowing the caller to make an arbitrary choice amongst them based on their metadata. Example partial implementation: clockutils.py. Working around operating system bugs? Should Python ensure that a monotonic clock is truly monotonic by computing the maximum with the clock value and the previous value? Since it's relatively straightforward to cache the last value returned using a static variable, it might be interesting to use this to make sure that the values r...
...enumerate all other types that may be used to represent bytes (e.g. some, but not all, instances of memoryview and array.array). Mapping Patterns Dictionaries or mappings in general are one of the most important and most widely used data structures in Python. In contrast to sequences, mappings are built for fast direct access to arbitrary elements identified by a key. In most cases an element is retrieved from a dictionary by a known key without regard for any ordering or other key-value pair...