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.
...Trait descriptors There are many designs of Python descriptors in the wild which, for example, check boundaries of values. Often those "traits" need some support of a metaclass to work. This is how this would look like with this PEP: class Trait: def __init__(self, minimum, maximum): self.minimum = minimum self.maximum = maximum def __get__(self, instance, owner): return instance.__dict__[self.key] def __set__(self, instance, value): if self.minimum...
...definition-time, and since the vast majority of attributes are defined at runtime by a class's __init__() method, there doesn't seem to be a good way to check for attributes at the same time as methods. It may still be desirable to include non-enforced attributes in the role definition, if only for documentation purposes. Roles of Roles Under the proposed semantics, it is possible for roles to have roles of their own. @perform_role(Y) class X(metaclass=Role): ... While this is possible, it...
...traits of the kind in question. name is the name of the kind. The standard kinds are called int, long, double. typecode is a single-letter string that would be appropriate for use with Numeric or module array to form an array of this kind. The standard types' typecodes are 'i', 'O', 'd' respectively. Integer kinds have these additional attributes: MAX, equal to the maximum permissible integer of this kind, or None for the long kind. MIN, equal to the most negative permissible integer of this ...
...trait for a few reasons. The most important one is that it allows these objects to be used as dictionary keys, which is potentially extremely valuable for certain TLS backends and their SNI configuration. On top of this, it frees implementations from needing to worry about their configuration objects being changed under their feet, which allows them to avoid needing to carefully synchronize changes between their concrete data structures and the configuration object. This object is extendable: th...