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.
...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 of the block statement from the PEP you could implement all the examples using a class (similar to example 6, which is easily turned into a template). But the key idea is using a generator to drive a block statement; the rest is elaboration, so I'd like to keep these two parts together. (PEP 342, Enhanced Iterators, was originally a part of this PEP; but the two proposals are really independent and with Steven Bethard's help I have moved it to a separate PEP.) Rejection Notice I am...
...definition would look like: def name(positional_or_keyword_parameters, *, keyword_only_parameters): Building on that example, the new syntax for function definitions would look like: def name(positional_only_parameters, /, positional_or_keyword_parameters, *, keyword_only_parameters): The following would apply: All parameters left of the / are treated as positional-only. If / is not specified in the function definition, that function does not accept any positional-only arguments. T...
...definition make it obvious what is happening; at the very least it should be obvious that new users can safely ignore it when writing their own code be a syntax "that ... [is] easy to remember once explained" not make future extensions more difficult be easy to type; programs that use it are expected to use it very frequently not make it more difficult to scan through code quickly. It should still be easy to search for all definitions, a particular definition, or the arguments that a function a...
...definition header. Specifically, it is proposed that class definitions be able to provide a class initialisation hook as follows: class Example: def __autodecorate__(cls): # This is invoked after the class is created, but before any # explicit decorators are called # The usual super() mechanisms are used to correctly support # multiple inheritance. The class decorator style signature helps # ensure that invoking the parent class is as simple as possib...
...definition process. Reduced chance of metaclass conflicts One of the big issues that makes library authors reluctant to use metaclasses (even when they would be appropriate) is the risk of metaclass conflicts. These occur whenever two unrelated metaclasses are used by the desired parents of a class definition. This risk also makes it very difficult to add a metaclass to a class that has previously been published without one. By contrast, adding an __init_subclass__ method to an existing type p...
...definitions and style sheets, called Local.DTD and Local.DSL, respectively. These allow for the introduction of additional document elements, and their renderings, on top of those provided by DocBook. For example, some of the teams at my company wanted features in the final Word document that amounted to arbitrary Word field-code support in the SGML. To support this, I wrote a local DocBook stylesheet and definition file pair (Local.DSL, Local.DTD) to emit the sequences in RTF corresponding to t...
Python Software Foundation: Vendor Policies Introduction Employee vs contractor Purpose Factors Form SS-8 Vendor Definition Invoices Invoice Contents Invoice Example Payment Terms Approval Process OFAC Sanctioned Countries Vendor Tax Documents Tax Withholding Domestic Individuals and Organizations Tax Withholding Form 1099 Foreign Individuals and Organizations Tax Withholding United States-Foreign Country Tax Treaties US Tax Identification Numbers Obtaining a US ITI...
...template protocol: __enter__ Statement template protocol: __exit__ Factoring out arbitrary exception handling Generators Default value for yield Template generator decorator: statement_template Template generator wrapper: __enter__() method Template generator wrapper: __exit__() method Injecting exceptions into generators Generator finalisation Generator finalisation: TerminateIteration exception Generator finalisation: __del__() method Deterministic generator finalisation Generators as user d...
...Definition", and pick one of the licenses mentioned there under "Example Licenses". You should INCLUDE YOUR E-MAIL ADDRESS in the body text of your posting or in the trailing .signature block. Please do not sign your announcement with PGP; most people would not know your public PGP key anyway and would get a warning message. Avoid excessive cross-posting. Messages that are cross-posted to several moderated news groups will usually be approved by the moderator of the first group ...
...definition. See python-dev discussion on 17 June 2005 [2]. Motivation To allow a programming style for selectable actions that is more in accordance with the minimalistic functional programming goals of the Python language. Rationale Allow the use of None in method tables as a universal no effect rather than either (1) checking a method table entry against None before calling, or (2) writing a local no effect method with arguments similar to other functions in the table. The semantics would ...
...definitions/requirementVersion" }, { "$ref": "#/definitions/requirementTable" }, { "title": "Multiple specifications", "type": "array", "items": { "$ref": "#/definitions/requirementTable" }, "minLength": 1 } ] }, "optionalRequirementTable": { ...
...definition to be: def noop(*args, **kwds): return args[0] if args else None The counterargument to the counterargument is that using None as the default in all these cases is going to be faster, since it lets the algorithm skip the callback entirely, rather than calling it and having it do nothing useful. References [1]https://github.com/python/cpython/pull/3480 Copyright This document has been placed in the public domain. Source: https://github.com/python/peps/blob/master/pep...
...definition outputs to sys.stdout. More specifically, sys.stdout must be a file-like object with a write() method, but it can be rebound to redirect output to files other than specifically standard output. A typical idiom is: save_stdout = sys.stdout try: sys.stdout = mylogfile print 'this message goes to my log file' finally: sys.stdout = save_stdout The problem with this approach is that the binding is global, and so affects every statement inside the try: clause. For example, ...
...definition, so that programmers are free to create variables, attributes, and methods that start with letters, without fear of silently colliding with names that have a language-defined purpose. (Colliding with reserved keywords is still a concern, but at least this will immediately yield a syntax error.) The naming of the next method on iterators is an exception to this convention. Code that nowhere contains an explicit call to a next method can nonetheless be silently affected by the presenc...
...Definition Language (ASDL) [Wang97]. The definition of the AST nodes for Python is found in the file Parser/Python.asdl . Each AST node (representing statements, expressions, and several specialized types, like list comprehensions and exception handlers) is defined by the ASDL. Most definitions in the AST correspond to a particular source construct, such as an 'if' statement or an attribute lookup. The definition is independent of its realization in any particular programming language. The fol...
...definition Legacy manylinux tags Package installers Package indexes Rejected alternatives Abstract This PEP proposes a scheme for new 'manylinux' wheel tags to be defined without requiring a PEP for every specific tag, similar to how Windows and macOS tags already work. This will allow package maintainers to take advantage of new tags more quickly, while making better use of limited volunteer time. Non-goals include: handling non-glibc-based platforms; integrating with external package mana...
...definition time. Instead, they are preserved in __annotations__ in string form. This change is being introduced gradually, starting with a __future__ import in Python 3.7. Rationale and Goals PEP 3107 added support for arbitrary annotations on parts of a function definition. Just like default values, annotations are evaluated at function definition time. This creates a number of issues for the type hinting use case: forward references: when a type hint contains names that have not been defi...
...definitions at that level: stmt: simple_stmt | compound_stmt simple_stmt: small_stmt (';' small_stmt)* [';'] NEWLINE small_stmt: (expr_stmt | del_stmt | pass_stmt | flow_stmt | import_stmt | global_stmt | nonlocal_stmt | assert_stmt) flow_stmt: break_stmt | continue_stmt | return_stmt | raise_stmt | yield_stmt In addition to the above changes, the definition of atom would be changed to also allow ?. The restriction of this usage to statements with an associated given clause would ...
...definitions for implicitly setting the attribute. This convenience has been exploited over and over again, overloading docstrings with additional semantics. For example, John Aycock has written a system where docstrings are used to define parsing rules. [1] Zope's ZPublisher ORB [2] uses docstrings to signal publishable methods, i.e. methods that can be called through the web. The problem with this approach is that the overloaded semantics may conflict with each other. For example, if we want...