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.
...interfaces For interoperability with interfaces that only accept strings, interpolation templates can still be prerendered with format, rather than delegating the rendering to the called function. This reflects the key difference from PEP 498, which always eagerly applies the default rendering, without any way to delegate the choice of renderer to another section of the code. Preserving the raw template string Earlier versions of this PEP failed to make the raw template string available on the...
...interface. People also seemed to accept the idea of "building" everything -- C modules, Python modules, eventually documentation -- to a temporary "build library" directory, tentatively called blib/. (This is one of the few implementation details of Perl's MakeMaker that survived the session.) The blib/directory serves (at least) two purposes: it makes installation near-trivial, and it provides a realistic-looking pseudo-installation tree for running test scripts. ...
...definitions, and major sections inside functions. Comments go before the code they describe. All functions and global variables should be declared static unless they are to be part of a published interface For external functions and variables, we always have a declaration in an appropriate header file in the "Include" directory, which uses the PyAPI_FUNC() macro and PyAPI_DATA() macro, like this: PyAPI_FUNC(PyObject *) PyObject_Repr(PyObject *); PyAPI_DATA(PyTypeObject) PySuper_Type; N...
...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...
...interface, which has now been rejected in favour of this PEP. The primary difference is that our build backend is defined via a Python hook-based interface rather than a command-line based interface. This appendix documents the arguments advanced for this PEP over PEP 516. We do not expect that specifying Python hooks rather than command line interfaces will, by itself, reduce the complexity of calling into the backend, because build frontends will in any case want to run hooks inside a child --...
...definition, class definition, or method definition, after any comments. This is the standard for Python __doc__ attributes. Immediately following a simple assignment at the top level of a module, class definition, or __init__ method definition, after any comments. See Attribute Docstrings below. Additional string literals found immediately after the docstrings in (a) and (b) will be recognized, extracted, and concatenated. See Additional Docstrings below. @@@ 2.2-style "properties" with attri...
...definition is a literal string, that string is assigned to the __doc__ attribute. The __doc__ attribute is called a documentation string, or docstring. It is often used to summarize the interface of the module, class or function. However, since there is no common format for documentation string, tools for extracting docstrings and transforming those into documentation in a standard format (e.g., DocBook) have not sprang up in abundance, and those that do exist are for the most part unmaintained ...
...interface). The Limited API is a subset of CPython's C API. Extensions that target the Limited API should define the preprocessor macro Py_LIMITED_API to either 3 or the current PYTHON_API_VERSION. This will enable Stable ABI versions of several functions and limit definitions to the Limited API. (However, note that the macro is not perfect: due to technical issues or oversights, some non-limited API might be exposed even with it defined.) The Limited API is not guaranteed to be stable. In the f...
...Interfaces ABCs are not intrinsically incompatible with Interfaces, but there is considerable overlap. For now, I'll leave it to proponents of Interfaces to explain why Interfaces are better. I expect that much of the work that went into e.g. defining the various shades of "mapping-ness" and the nomenclature could easily be adapted for a proposal to use Interfaces instead of ABCs. "Interfaces" in this context refers to a set of proposals for additional metadata elements attached to a class whi...
...interface. The docstring for a class should summarize its behavior and list the public methods and instance variables. If the class is intended to be subclassed, and has an additional interface for subclasses, this interface should be listed separately (in the docstring). The class constructor should be documented in the docstring for its __init__ method. Individual methods should be documented by their own docstring. If a class subclasses another class and its behavior is mostly inherited fr...
...interfaces for the benefit of people working on the IDLE code is a separate issue.) Third are people who write IDLE extensions. The guaranteed extension interface is given in idlelib/extension.txt. This should be respected at least in existing versions, and not frivolously changed in future versions. But there is a warning that "The extension cannot assume much about this [EditorWindow] argument." This guarantee should rarely be an issue with patches, and the issue is not specific to 'enhanc...
...definitions during evaluation of the class body. In other words, the class body is evaluated as a function block (just like it is now), except that the local variables dictionary is replaced by the dictionary returned from __prepare__. This dictionary object can be a regular dictionary or a custom mapping type. This dictionary-like object is not required to support the full dictionary interface. A dictionary which supports a limited set of dictionary operations will restrict what kinds of action...
...definition file. Like YACC, YAPPS supports custom code before and after the grammar definition. YAPPS parsers integrate with the scanner through a Scanner object, which is passed to the parser as a constructor argument. Even though YAPPS supports definition of tokens in the grammar, we have not used this capability in XPath, since we have provided my own scanner class. The YAPPS parser will only require a token() method from the scanner object, which must return a four-tuple (start, e...
...interface to objects, where unadorned attribute access and modification is transparently mapped to a functional interface. E.g. class Bean: def __init__(self, x): self.__myfoo = x def __findattr__(self, name, *args): if name.startswith('_'): # Private names if args: setattr(self, name, args[0]) else: return getattr(self, name) else: # Public names if args: name = '_set_' + name else: ...
...interfaces, where the transport wraps some other communication abstraction. Examples include interfaces for sending and receiving datagrams (e.g. UDP), or a subprocess manager. The separation of concerns is the same as for bidirectional stream transports and protocols, but the specific interface between transport and protocol is different in each case. Details of the interfaces defined by the various standard types of transports and protocols are given later. Event Loop Interface Specificat...
...interface can be reasonably low. Thus, simplicity of implementation on both the server and framework sides of the interface is absolutely critical to the utility of the WSGI interface, and is therefore the principal criterion for any design decisions. Note, however, that simplicity of implementation for a framework author is not the same thing as ease of use for a web application author. WSGI presents an absolutely "no frills" interface to the framework author, because bells and whistles like r...
...interface is not a good hack to work around the 31 bit limitation of the length. If you don't know what this means, then you're in good company. Most code in the Python baseline, and presumably in many third party extensions, punt when the segment count is not 1. References [1]The buffer interface https://mail.python.org/pipermail/python-dev/2000-October/009974.html Copyright This document has been placed in the public domain. Source: https://github.com/python/peps/blob/master/pep...
...interface for application developers. Transports talk to two things: the other side of the connection on one hand, and a protocol on the other. It's a bridge between the specific underlying transfer mechanism and the protocol. Its job can be described as allowing the protocol to just send and receive bytes, taking care of all of the magic that needs to happen to those bytes to be eventually sent across the wire. The primary feature of a transport is sending bytes to a protocol and receiving by...
...Interfaces Notes / TBD Acknowledgements References Copyright Abstract This document proposes "Argument Clinic", a DSL to facilitate argument processing for built-in functions in the implementation of CPython. Rationale and Goals The primary implementation of Python, "CPython", is written in a mixture of Python and C. One implementation detail of CPython is what are called "built-in" functions -- functions available to Python programs but written in C. When a Python program calls a built...
...definition overrides the dynamic definition, but for other attributes, dynamic overrides static. Rationale: we can't have a simple rule like "static overrides dynamic" or "dynamic overrides static", because some static attributes indeed override dynamic attributes; for example, a key '__class__' in an instance's __dict__ is ignored in favor of the statically defined __class__ pointer, but on the other hand most keys in inst.__dict__ override attributes defined in inst.__class__. Presence of a _...