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.
...Alias = int # type alias x: TypeAlias = "MyClass" # type alias Note: The examples above illustrate implicit and explicit alias declarations in isolation. For the sake of backwards compatibility, type checkers should support both simultaneously, meaning an untyped global expression x = int will still be considered a valid type alias. Backwards Compatibility Explicit aliases provide an alternative way to declare type aliases, but all pre-existing code and old alias declarations will work as b...
...aliasing The attrs library performs automatic aliasing of field names that start with a single underscore, stripping the underscore from the name of the corresponding __init__ parameter. This proposal omits that behavior since it is specific to attrs. Users can manually alias these fields using the alias parameter. Alternate field ordering algorithms The attrs library currently supports two approaches to ordering the fields within a class: Dataclass order: The same ordering used by dataclasse...
...declarations will not change their parameters or return types. If a change to the signature becomes necessary, a new function will be introduced. If the new function is source-compatible (e.g. if just the return type changes), an alias macro may get added to redirect calls to the new function when the applications is recompiled. If continued provision of the old function is not possible, it may get deprecated, then removed, causing applications that use that function to break. Excluded Functio...
...Alias for Union[t1, None], i.e. Union[t1, type(None)]. Tuple[t1, t2, ..., tn]. A tuple whose items are instances of t1, etc. Example: Tuple[int, float] means a tuple of two items, the first is an int, the second is a float; e.g., (42, 3.14). Tuple[u1, u2, ..., um] is a subtype of Tuple[t1, t2, ..., tn] if they have the same length n==m and each ui is a subtype of ti. To spell the type of the empty tuple, use Tuple[()]. A variadic homogeneous tuple type can be written Tuple[t1, ...]. (That's thre...
...aliases Type aliases are defined by simple variable assignments: Url = str def retry(url: Url, retry_count: int) -> None: ... Note that we recommend capitalizing alias names, since they represent user-defined types, which (like user-defined classes) are typically spelled that way. Type aliases may be as complex as type hints in annotations -- anything that is acceptable as a type hint is acceptable in a type alias: from typing import TypeVar, Iterable, Tuple T = TypeVar('T', int, float, ...
...declaration, specifying the metaclass to be used to create the new class a class statement can contain a __slots__ declaration, specifying the specific names of the instance variables supported This PEP builds on PEP 252, which adds standard introspection to types; for example, when a particular type object initializes the tp_hash slot, that type object has a __hash__ method when introspected. PEP 252 also adds a dictionary to type objects which contains all methods. At the Python level, this...
...alias to PyObject_New()), PyObject_NEW_VAR() (alias to PyObject_NewVar()) PyType_HasFeature() (always call PyType_GetFlags()) Py_TRASHCAN_BEGIN_CONDITION() and Py_TRASHCAN_END() macros now call functions which hide implementation details, rather than accessing directly members of the PyThreadState structure. Make structures opaque The following structures of the C API become opaque: PyInterpreterState PyThreadState PyGC_Head PyTypeObject PyObject and PyVarObject PyTypeObject All types which ...
...aliases Protocols are essentially anonymous. To emphasize this point, static type checkers might refuse protocol classes inside NewType() to avoid an illusion that a distinct type is provided: from typing import NewType, Protocol, Iterator class Id(Protocol): code: int secrets: Iterator[bytes] UserId = NewType('UserId', Id) # Error, can't provide distinct type In contrast, type aliases are fully supported, including generic type aliases: from typing import TypeVar, Reversible, Iter...
...alias psf-domains at python.org was setup, so that the board list no longer gets all the domain email. Issues Some transfer problems like emails not coming through, but nothing serious. 6 Oregon University Open Source Labs Donation RESOLVED, that the PSF make a donation to the Oregon State University Foundation for the Oregon State University Open Source Labs in the amount of $3000 Approved, 11-0-0. 7 Python Dominicana Grant RESOLVED, that the PSF...
PEP 492 -- Coroutines with async and await syntax PEP:492 Title:Coroutines with async and await syntax Author:Yury Selivanov <yury at edgedb.com> Discussions-To:python-dev at python.org Status:Final Type:Standards Track Created:09-Apr-2015 Python-Version:3.5 Post-History:17-Apr-2015, 21-Apr-2015, 27-Apr-2015, 29-Apr-2015, 05-May-2015 Contents Abstract API Design and Implementation Revisions Rationale and Goals Specification New Coroutine Declaration Syntax types.corouti...
...aliases containing Self. Supporting Self outside class definitions can require a lot of special-handling in type checkers. Given that it also goes against the rest of the PEP to use Self outside a class definition, we believe the added convenience of aliases is not worth it: TupleSelf = Tuple[Self, Self] # Rejected class Alias: def return_tuple(self) -> TupleSelf: # Rejected return (self, self) Note that we reject Self in staticmethods. Self does not add much value since ther...
...alias for bool(); that's fine.) Should bool inherit from int? => Yes. In an ideal world, bool might be better implemented as a separate integer type that knows how to perform mixed-mode arithmetic. However, inheriting bool from int eases the implementation enormously (in part since all C code that calls PyInt_Check() will continue to work -- this returns true for subclasses of int). Also, I believe this is right in terms of substitutability: code that requires an int can be fed a bool and ...
...alias list. It's public and anyone can subscribe to it: https://wiki.python.org/moin/PythonEventsCalendar#Mailing_List Submissions sent to events at python.org are forwarded to this mailing list. I ran a blog post and announcement earlier this month to call for submission of events for 2014. This was well received and we're getting a continuous stream of additions. I also setup a new feed for the calendars on Twitter using IFTTT: https://twitter.com/pythonevents This gets all newly added events ...
...aliases for CJK Mac encodings to resolve a build problem on MacOS with CJK locales. It adds four temporary mappings to existing legacy codecs that are virtually compatible with Mac encodings. They will be replaced by codecs correctly implemented in 3.1. Issue #3614: Corrected a typo in xmlrpc.client, leading to a NameError "global name 'header' is not defined". Issue #2834: update the regular expression library to match the unicode standards of py3k. In other words, mixing bytes and ...
...aliases: Alias = Optional['<type>'] AnotherAlias = Union['<type>', '<type>'] YetAnotherAlias = '<type>' casting: cast('<type>', value) base classes: class C(Tuple['<type>', '<type>']): ... Depending on the specific case, some of the cases listed above might be worked around by placing the usage in a if TYPE_CHECKING: block. This will not work for any code that needs to be available at runtime, notably for base classes and casting. For named tu...
...alias for the ASCII-based default C locale. The simplest way to get Python 3 (regardless of the exact version) to behave sensibly in Fedora and Debian based containers is to run it in the C.UTF-8 locale that both distros provide: $ docker run --rm -e LC_CTYPE=C.UTF-8 fedora:25 python3 -c 'print("ℙƴ☂ℌøἤ")' ℙƴ☂ℌøἤ $ docker run --rm -e LC_CTYPE=C.UTF-8 ncoghlan/debian-python python3 -c 'print("ℙƴ☂ℌøἤ")' ℙƴ☂ℌøἤ $ docker run --rm -e LC_CTYPE=C.UTF-8 fedora:25 locale | grep -E 'LC_ALL|LC_CTYPE|LANG'...
...aliases first before starting to try the import of the codec module. This simplifies overriding built-in codecs with external packages, e.g. the included CJK codecs with the JapaneseCodecs package, by adjusting the aliases dictionary in encodings.aliases accordingly. base64 now supports RFC 3548 Base16, Base32, and Base64 encoding and decoding standards. urllib2 now supports processors. A processor is a handler that implements an xxx_request or xxx_response method. These methods are called for...
...declarations uniformly use type hints to aid reading. Some of these type hints cannot actually be used in practice because they are circularly referential. Consider them more a guideline than a reflection of the final code in the module. Configuration The TLSConfiguration concrete class defines an object that can hold and manage TLS configuration. The goals of this class are as follows: To provide a method of specifying TLS configuration that avoids the risk of errors in typing (this excludes...
...alias as well): arr = np.array(5) arr.ndim == 0 arr[None].ndim == arr[None,].ndim == 1 While this is not an insurmountable issue, it certainly will ripple onto numpy. The only issues with both the above is that both the empty tuple and None are potential legitimate indexes, and there might be value in being able to differentiate the two degenerate cases. So, an alternative strategy (option 3) would be to use an existing entity that is unlikely to be used as a valid index. One option could be t...
...alias for bytes and the b"foo" literal syntax. This is why it is the minimum version supported by Web3. Explicability and documentability are the main technical drivers for the decisions made within the standard. Differences from WSGI All protocol-specific environment names are prefixed with web3. rather than wsgi., eg. web3.input rather than wsgi.input. All values present as environment dictionary values are explicitly bytes instances instead of native strings. (Environment keys however a...