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 value. This results in using such values in contexts where the enumeration has no meaning, and unnecessarily complicates the design. The enumerated values specified in this PEP export the values used to create them, and can be compared for equality with any other value, but sequence comparison with values outside the enumeration is explicitly not implemented. Hiding attributes of enumerated values A previous design had the enumerated values hiding as much as possible about their im...
PEP 435 -- Adding an Enum type to the Python standard library PEP:435 Title:Adding an Enum type to the Python standard library Author:Barry Warsaw <barry at python.org>, Eli Bendersky <eliben at gmail.com>, Ethan Furman <ethan at stoneleaf.us> Status:Final Type:Standards Track Created:23-Feb-2013 Python-Version:3.4 Post-History:23-Feb-2013, 02-May-2013 Replaces:354 Resolution:https://mail.python.org/pipermail/python-dev/2013-May/126112.html Contents Abstrac...
...enumerate() built-in function PEP:279 Title:The enumerate() built-in function Author:python at rcn.com (Raymond Hettinger) Status:Final Type:Standards Track Created:30-Jan-2002 Python-Version:2.3 Post-History: Contents Abstract Rationale BDFL Pronouncements Specification for a new built-in Copyright Abstract This PEP introduces a new built-in function, enumerate() to simplify a commonly used looping idiom. It provides all iterable collections with the same advantage that i...
...enumerate' built-in could be extended to support __copy__ if its underlying iterator also supported __copy__: class enumerate(object): def __init__(self, it): self.it = iter(it) self.i = -1 def __iter__(self): return self def next(self): self.i += 1 return self.i, self.it.next() def __copy__(self): result = self.__class__.__new__() result.it = self.it.__copy__() result.i = self.i return result Here is a...
...enumerate(dependencies, 1): if not isinstance(entry, str): raise TypeError(f'Dependency #{i} of field `project.dependencies` must be a string') try: Requirement(entry) except InvalidRequirement as e: raise ValueError(f'Dependency #{i} of field `project.dependencies` is invalid: {e}') return dependencies def parse_optional_dependencies(config): optional_dependencies = config.get('optional-dependencies', {}) if not isinstan...
PEP 663 -- Standardizing Enum str(), repr(), and format() behaviors PEP:663 Title:Standardizing Enum str(), repr(), and format() behaviors Author:Ethan Furman <ethan at stoneleaf.us> Discussions-To:python-dev at python.org Status:Rejected Type:Informational Created:30-Jun-2021 Python-Version:3.11 Post-History:20-Jul-2021, 02-Nov-2021 Resolution:https://mail.python.org/archives/list/python-dev@python.org/message/RN3WCRZSTQR55DOHJTZ2KIO6CZPJPCU7/ Contents Abstract Motiva...
...enumerate(self._variable_names) } return self._name_to_offset_mapping_impl class FrameType: _locals : array[Object] # The values of the local variables, items may be NULL. _extra_locals: dict | NULL # Dictionary for storing extra locals not in _locals. def __init__(self, ...): self._extra_locals = NULL ... @property def f_locals(self): return FrameLocalsProxy(self) class FrameLocalsProxy: "Implements collections.MutableMapp...
PEP 552 -- Deterministic pycs PEP:552 Title:Deterministic pycs Author:Benjamin Peterson <benjamin at python.org> Status:Final Type:Standards Track Created:04-Sep-2017 Python-Version:3.7 Post-History:07-Sep-2017 Resolution:https://mail.python.org/pipermail/python-dev/2017-September/149649.html Contents Abstract Rationale Specification References Credits Copyright Abstract This PEP proposes an extension to the pyc format to make it more deterministic. Rationale A rep...
...enumerated the tasks necessary to develop, distribute, and install Python modules; arrived at a rough consensus regarding the division of labour necessary to conceptualize any distribution/installation system; and came up with a proposed user interface. This document describes the tasks and division of labour; the proposed user interface is described elsewhere. Three roles were identified: the developer, the packager, and the installer (in one sense, th...
...Enumerate this:") ... for i, elem in enumerate(arg): ... print(i, elem) To enable registering lambdas and pre-existing functions, the register() attribute can be used in a functional form: >>> def nothing(arg, verbose=False): ... print("Nothing.") ... >>> fun.register(type(None), nothing) The register() attribute returns the undecorated function. This enables decorator stacking, pickling, as well as creating unit tests for each variant independently: >>...
...Enumerated (numbered) list items are similar, but use an enumerator instead of a bullet. Enumerators are numbers (1, 2, 3, ...), letters (A, B, C, ...; uppercase or lowercase), or Roman numerals (i, ii, iii, iv, ...; uppercase or lowercase), formatted with a period suffix ("1.", "2."), parentheses ("(1)", "(2)"), or a right-parenthesis suffix ("1)", "2)"). For example: 1. As with bullet list items, the left edge of paragraphs must align. 2. Each list item may contain multiple paragraphs, ...
...enumerated types. The resulting classes are never instantiated -- rather, their class attributes are the enumerated values. For example: class Color(Enum): red = 1 green = 2 blue = 3 print Color.red will print the string ``Color.red'', while ``Color.red==1'' is true, and ``Color.red + 1'' raise a TypeError exception. Trace.py The resulting classes work much like standard classes, but by setting a special class or instance attribute __trace_output__ to p...
...enumerate() function, this PEP's author offered, "I'm quite happy to have it make PEP 281 obsolete." Subsequently, PEP 279 was accepted into Python 2.3. On 17 June 2005, the BDFL concurred with it being obsolete and hereby rejected the PEP. For the record, he found some of the examples to somewhat jarring in appearance: >>> range(range(5), range(10), range(2)) [5, 7, 9] Motivation It is often desirable to loop over the indices of a sequence. PEP 212 describes several ways of doing...
PEP 264 -- Future statements in simulated shells PEP:264 Title:Future statements in simulated shells Author:Michael Hudson <mwh at python.net> Status:Final Type:Standards Track Requires:236 Created:30-Jul-2001 Python-Version:2.2 Post-History:30-Jul-2001 Contents Abstract Specification Backward Compatibility Forward Compatibility Issues Implementation References Copyright Abstract As noted in PEP 236, there is no clear way for "simulated interactive shells" to simulat...
...enumerate(), the function needs to be directly accessible in daily programming. Each solves a basic looping problem: lock-step iteration, loop counting, and reverse iteration. Requiring some form of dotted access would interfere with their simplicity, daily utility, and accessibility. They are core looping constructs, independent of any one application domain. Copyright This document has been placed in the public domain. Source: https://github.com/python/peps/blob/master/pep-0322.txt
...enumerate(), {}.pop(), PendingDeprecationWarning, Universal Newlines, plus all features below plus all features below 2.3 generator expressions, multi-line imports, decorators, int/long unification, set/frozenset, reversed(), sorted(), "".rsplit(), plus all features below 2.4 with statement, conditional expressions, combined try/except/finally, relative imports, yield expressions or generator.throw/send/close(), plus all features below 2.5 with statement without from __future__ import, io mod...
PEP 550 -- Execution Context PEP:550 Title:Execution Context Author:Yury Selivanov <yury at edgedb.com>, Elvis Pranskevichus <elvis at edgedb.com> Status:Withdrawn Type:Standards Track Created:11-Aug-2017 Python-Version:3.7 Post-History:11-Aug-2017, 15-Aug-2017, 18-Aug-2017, 25-Aug-2017, 01-Sep-2017 Contents Abstract PEP Status Rationale Goals High-Level Specification Regular Single-threaded Code Multithreaded Code Generators Coroutines and Asynchronous Tasks Det...
...enumerate(), introduced in PEP 279, covers the use-case proposed in this PEP, and the PEP author has been unreachable. Introduction This PEP describes the often proposed feature of exposing the loop counter in for-loops. This PEP tracks the status and ownership of this feature. It contains a description of the feature and outlines changes necessary to support the feature. This PEP summarizes discussions held in mailing list forums, and provides URLs for further information, where appropriat...
...enumerate(iterators[1:], 1): if next(iterator, sentinel) is not sentinel: plural = " " if i == 1 else "s 1-" msg = f"zip() argument {i+1} is longer than argument{plural}{i}" raise ValueError(msg) Rejected Ideas Add itertools.zip_strict This is the alternative with the most support on the Python-Ideas mailing list, so it deserves to be discussed in some detail here. It does not have any disqualifying flaws, and could work well enough as a substitut...