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.
...if you have two files, FiLe.py and file.py on sys.path, and do import file then if Python finds FiLe.py first, it raises a NameError. It does not go on to find file.py; indeed, it's impossible to import any but the first case-insensitive match on sys.path, and then only if case matches exactly in the first case-insensitive match. An ugly exception: if the first case-insensitive match on sys.path is for a file whose name is entirely in upper case (FILE.PY or FILE.PYC or FILE.PYO), then the imp...
...existing in both Python 2.7 and Python 3.5 In order to facilitate writing code that works in both Python 2 & 3 simultaneously, any module that exists in both Python 3.5 and Python 2.7 will not be removed from the standard library until Python 2.7 is no longer supported as specified by PEP 373. Exempted from this rule is any module in the idlelib package as well as any exceptions granted by the Python development team. Procedure for declaring a module undeprecated When a module becomes dep...
...ifically on the 2-argument extension.) Finally, the new syntax can be used with the "del" statement, as in: del x.(attr_name) Impact On Existing Code The proposed new syntax is not currently valid, so no existing well-formed programs have their meaning altered by this proposal. Across all "*.py" files in the 2.5 distribution, there are around 600 uses of "getattr", "setattr" or "delattr". They break down as follows (figures have some room for error because they were arrived at by partially-...
...exists are defined as: def forall(a, fn = bool): """Return True only if all elements in a are true. >>> forall([]) 1 >>> even = lambda x: x % 2 == 0 >>> forall([2, 4, 6, 8], even) 1 >>> forall('this is a test'.split(), lambda x: len(x) == 4) 0 """ def exists(a, fn = bool): """Returns True if there is at least one true value in a. >>> exists([]) 0 >>> exists('this is a test'.split(), lamb...
...existing syntax lines = bdata.split(b'\n') # proposed syntax And when converting code from Python 2.x to Python 3000: sok.send('EXIT\r\n') # Python 2.x sok.send('EXIT\r\n'.encode('ascii')) # Python 3000 existing sok.send(b'EXIT\r\n') # proposed Grammar Changes The proposed syntax is an extension of the existing string syntax [1]. The new syntax for strings, including the new bytes literal, is: stringliteral: [stringprefix] (shortstring | longstring) stringprefix: "b" | "r" | "br" | "B"...
Python Software Foundation GitHub Organization Purpose The Python Software Foundation exists to promote, protect, and advance the Python programming language, to fulfill that mission we have created a GitHub organization, @psf, to support and protect projects that have outgrown ownership by their original author. What is offered Repositories may be transferred to the @psf organization under the following criteria: The repository is relevant to the Python ecosystem at large and has broad inter...
...Existing Systems Specification Project Web Site References and Footnotes Copyright Acknowledgements Rejection Notice This proposal seems to have run out of steam. Abstract Python lends itself to inline documentation. With its built-in docstring syntax, a limited form of Literate Programming is easy to do in Python. However, there are no satisfactory standard tools for extracting and processing Python docstrings. The lack of a standard toolset is a significant gap in Python's infrastruc...
...exist and are actively being hired for) where the successful candidate will spend the majority of their time writing Python. If this isn't the case, the submission will most likely be rejected. Unpaid volunteer positions will not be posted on the jobs page. If you have some Python-related volunteer post, please post a description in the Wiki on the Volunteer Opportunities page; register with the Wiki and then follow the "EditText" link on the Wiki page. The Job Board is run by voluntee...
...existing terms with which people may not be so familiar. For the sake of context, here is a brief summary of all three groups of terms and concepts. A more detailed explanation of the import system is found at [2]. name In this proposal, a module's "name" refers to its fully-qualified name, meaning the fully-qualified name of the module's parent (if any) joined to the simple name of the module by a period. finder A "finder" is an object that identifies the loader that the import system shou...
...ifiers on PyPI: it is important that these identifiers remain human-readable. it is even better when these identifiers are meaningful. but the primary purpose of identifiers is not to classify or describe projects. Classifiers and keywords metadata are made for categorization of distributions. Summary and description metadata are meant to describe the project. As an example, there is a "Framework :: Twisted" classifier. Even if names are quite heterogeneous (they don't follow a particular patt...
...ifications defined by the PyPA. Processes The processes for the PyPA's activities are outlined below: Specifications The PyPA will use PEPs for defining, and making changes to, the interoperability specifications maintained by the PyPA. Thus, the Python Steering Council has the final say in the acceptance of these interoperability specifications. It is expected (but not required) that the Python Steering Council would delegate authority to sponsor and/or approve/reject PEPs related to packa...
...if my cell phone were programmable, I would still use the regular declarative interface (i.e. the keypad) to dial a specific number, since that's the most convenient way to access that specific functionality. However, without programmability, there is no way I can make it try a couple of different numbers for a particular friend until one is answered, unless the cell phone vendor anticipated this particular feature. 3. Challenges Some questions arise immediately. What would the pro...
...ific internal representation if possible. As interaction with other libraries will often require some sort of internal representation, the specification chooses UTF-8 as the recommended way of exposing strings to C code. For many strings (e.g. ASCII), multiple representations may actually share memory (e.g. the shortest form may be shared with the UTF-8 form if all characters are ASCII). With such sharing, the overhead of compatibility representations is reduced. If representations do share data...
...if c.objptr is not NULL] def values(self): preturn [c.objptr for c in self.__dict.itervalues() if c.objptr is not NULL] def clear(self): for c in self.__dict.values(): c.objptr = NULL # Etc. It is possible that a cell exists corresponding to a given key, but the cell's objptr is NULL; let's call such a cell empty. When the celldict is used as a mapping, it is as if empty cells don't exist. However, once added, a cell is never deleted ...
...if they can handle a given path item. The callable is called with one argument, the path item. The callable must raise ImportError if it is unable to handle the path item, and return an importer object if it can handle the path item. Note that if the callable returns an importer object for a specific sys.path entry, the builtin import machinery will not be invoked to handle that entry any longer, even if the importer object later fails to find a specific module. The callable is typically the...
...ifest simply as "Python has hung". While the biggest problem in the existing thread-state API is the lack of the ability to query the current state of the lock, it is felt that a more complete, simplified solution should be offered to extension authors. Such a solution should encourage authors to provide error-free, complex extension modules that take full advantage of Python's threading mechanisms. Limitations and Exclusions This proposal identifies a solution for extension authors with comp...
...if it exists. The Look Before You Leap (LBYL) idiom suffers from an obvious race condition: if os.path.exists(filename): os.remove(filename) If a file named as filename is created by another thread or process between the calls to os.path.exists and os.remove, it won't be deleted. This can produce bugs in the application, or even security issues. Therefore, the solution is to try to remove the file, and ignore the error if the file doesn't exist (an idiom known as Easier to Ask Forgivenes...
...ifferent type). frozendict doesn't convert anything: hash(frozendict) raises a TypeError if a value is not hashable. Freezing an object is not the purpose of this PEP. Alternative: dictproxy Python has a builtin dictproxy type used by type.__dict__ getter descriptor. This type is not public. dictproxy is a read-only view of a dictionary, but it is not read-only mapping. If a dictionary is modified, the dictproxy is also modified. dictproxy can be used using ctypes and the Python C API, see fo...
...If you want to take over an existing project name on PyPI, these are the steps to follow: Try to contact the current owner(s) directly: email them and open an issue if you can find a related repository. The processes described here are meant as a last resort if the owner cannot be contacted. Check the criteria above to see when a transfer is allowed. In particular, the criteria for reusing a name for a different project are more stringent than for continuing maintenance of the same project - al...
...ification Reference Implementation Rejected Ideas Use NotGiven = object() Add a single new sentinel value, e.g. MISSING or Sentinel Use the existing Ellipsis sentinel value Use a single-valued enum A sentinel class decorator Using class objects Define a recommended "standard" idiom, without supplying an implementation Additional Notes References Copyright TL;DR: See the Specification and Reference Implementation. Abstract Unique placeholder values, commonly known as "sentinel values", are u...