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.
...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(), lambda x: len(x) == 4) 1 """ An exampl...
...bool: get the close-on-exec flag of a file descriptor. Not available on all platforms. os.set_cloexec(fd:int, cloexec:bool=True): set or clear the close-on-exec flag on a file descriptor. Not available on all platforms. sys.getdefaultcloexec() -> bool: get the current default value of the cloexec parameter sys.setdefaultcloexec(cloexec: bool): set the default value of the cloexec parameter Add a new optional cloexec parameter to: asyncore.dispatcher.create_socket() io.FileIO io.open() open(...
...bool, True, False, basestring, enumerate(), {}.pop(), PendingDeprecationWarning, Universal Newlines, plus all features below plus all features below 2.3 generator expressions, multi-line imports, decorators, int/long unification, set/frozenset, reversed(), sorted(), "".rsplit(), plus all features below 2.4 with statement, conditional expressions, combined try/except/finally, relative imports, yield expressions or generator.throw/send/close(), plus all features below 2.5 with statement without...
...bool): set the inheritable flag of the specified file descriptor. New functions only available on Windows: os.get_handle_inheritable(handle: int): return True if the handle can be inherited by child processes, False otherwise. os.set_handle_inheritable(handle: int, inheritable: bool): set the inheritable flag of the specified handle. New methods: socket.socket.get_inheritable(): return True if the socket can be inherited by child processes, False otherwise. socket.socket.set_inheritable(inhe...
...bool The TypedDict XYZ has three items: x (type int), y (type str), and z (type bool). A TypedDict cannot inherit from both a TypedDict type and a non-TypedDict base class. Additional notes on TypedDict class inheritance: Changing a field type of a parent TypedDict class in a subclass is not allowed. Example: class X(TypedDict): x: str class Y(X): x: int # Type check error: cannot overwrite TypedDict field "x" In the example outlined above TypedDict class annotations returns type str...
...bool that adds the element x if it isn't already in the set. It should return True if x was added, False if it was already there. The abstract implementation raises NotImplementedError. .discard(x) Abstract method returning a bool that removes the element x if present. It should return True if the element was present and False if it wasn't. The abstract implementation raises NotImplementedError. .pop() Concrete method that removes and returns an arbitrary item. If the set is empty, it raises ...
...bool) # &, |, ^, - (returning a new, real set object) # # as well as their method counterparts (.union(), etc.). # # To specify the semantics, we can specify x == y as: # # set(x) == set(y) if both x and y are d_keys instances # set(x) == y if x is a d_keys instance # x == set(y) if y is a d_keys instance # # and so on for all other operations. class d_items: def __init__(self, d): self.__d = d def __len__...
...bool = False follow_symlinks: bool = True Use the real uid/gid to test for access to a path. Returns True if granted, False otherwise. {parameters} dir_fd, effective_ids, and follow_symlinks may not be implemented on your platform. If they are unavailable, using them will raise a NotImplementedError. Note that most operations will use the effective uid/gid, therefore this routine can be used in a suid/sgid environment to test if the invoking user has the specified access to the pa...
...bool Is the interpreter currently executing code? .close() Finalize and destroy the interpreter. .run(src_str, /, *, channels=None) Run the given source code in the interpreter. (This blocks the current thread until done.) exception base description RunFailedError RuntimeError Interpreter.run() resulted in an uncaught exception. For sharing data between interpreters: signature description is_shareable(obj) -> Bool Can the object's data be shared between inter...
...bool """Returns True if self.name matches the given pattern.""" def matchcase(self, pattern) => bool """ Like match() but is guaranteed to be case sensitive even on platforms with case insensitive filesystems. """ def glob(self, pattern): # Methods for retrieving information about the filesystem # path: def exists(self): ... def isabs(self): ... def isdir(self): ... def isfile(self): ... def islink(self): ... de...
...bool, min_dt)) print("min time_ns() delta: %s ns" % min_dt) min_dt = [abs(time.time() - time.time()) for _ in range(LOOPS)] min_dt = min(filter(bool, min_dt)) print("min time() delta: %s ns" % math.ceil(min_dt * 1e9)) Linux Clocks resolution measured in Python on Fedora 26 (kernel 4.12): Function Resolution clock() 1 us monotonic() 81 ns monotonic_ns() 84 ns perf_counter() 82 ns perf_counter_ns() 84 ns process_time() 2 ns process_time_ns() 1 ns resource.getrusage() ...
...bool) -> None: if set_attr: self.attr = 10 def foo(set_attr: bool) -> None: if set_attr: attr = 10 reveal_type(attr) # int|Missing Misalignment with how unions apply to values However this use of ...|Missing, equivalent to Union[..., Missing], doesn’t align well with what a union normally means: Union[...] always describes the type of a value that is present. By contrast missingness or non-totality is a property of a variable instead. Current preced...
...bool ✓ (CHECK MARK) complex ℂ (DOUBLE-STRUCK CAPITAL C) str ✎ (LOWER RIGHT PENCIL) unicode ✒ (BLACK NIB) tuple ⒯ (PARENTHESIZED LATIN SMALL LETTER T) list ♨ (HOT SPRINGS) dict ⧟ (DOUBLE-ENDED MULTIMAP) set ∅ (EMPTY SET) (Note: this is also for full sets) frozenset ☃ (SNOWMAN) datetime ⌚ (WATCH) function ƛ (LATIN SMALL LETTER LAMBDA WITH STROKE) generator ⚛ (ATOM SYMBOL) Exception ⌁ (ELECTRIC ARROW) The declarator for the None type is a zero-width space. These characters should be ...
...bool. Reference Implementation Submitted as patch 1436368 to SourceForge. References [1]Travis Oliphant, PEP for adding an sq_index slot so that any object, a or b, can be used in X[a:b] notation, https://mail.python.org/pipermail/python-dev/2006-February/thread.html#60594 Copyright This document is placed in the public domain. Source: https://github.com/python/peps/blob/master/pep-0357.txt
...bool(), .real, .imag, +, -, *, /, **, abs(), .conjugate(), ==, and !=. If it is given heterogeneous arguments, and doesn't have special knowledge about them, it should fall back to the builtin complex type as described below. """ @abstractmethod def __complex__(self): """Return a builtin complex instance.""" def __bool__(self): """True if self != 0.""" return self != 0 @abstractproperty def real(self): """Retrieve the re...
...bool type and its constants, True and False (PEP 285). PyMalloc was greatly enhanced and is enabled by default. Universal newline support (PEP 278). PEP 263 Defining Python Source Code Encodings, Lemburg Implemented (at least phase 1, which is all that's planned for 2.3). Extended slice notation for all built-in sequences. The patch by Michael Hudson is now all checked in. Speed up list iterations by filling tp_iter and other tweaks. See https://bugs.python.org/issue560736; also done for x...
...boolean attribute on the _manylinux module described in PEP 513. A platform is considered incompatible with manylinux2014 if the attribute is False. If the _manylinux module is not found, or it does not have the attribute manylinux2014_compatible, tools may fall back to checking for glibc. If the platform has glibc 2.17 or newer, it is assumed to be compatible unless the _manylinux module says otherwise. Specifically, the algorithm we propose is: def is_manylinux2014_compatible(): # Only Li...
...bool, has been added, as well as built-in names for its two values, True and False. Comparisons and sundry other operations that return a truth value have been changed to return a bool instead. Read PEP 285 for an explanation of why this is backward compatible. Fixed two bugs reported as SF #535905: under certain conditions, deallocating a deeply nested structure could cause a segfault in the garbage collector, due to interaction with the "trashcan" code; access to the current frame...
...bool>" optional argument seems utterly application-specific. I would like to reject this because it doesn't solve a general enough problem in a general enough way, it just clutters the dictionary API. I'd rather add dict.popitem(key). PEP 266 - Optimizing Global Variable/Attribute Access Montanaro PEP 267 - Optimized Access to Module Namespaces - Hylton PEP 280 - Optimizing access to globals - van Rossum These three should be considered together; at most one of them can be impl...
...bool): True if the clock cannot go backward. adjustable (bool): True if the clock can be changed automatically (e.g. by a NTP daemon) or manually by the system administrator, False otherwise resolution (float): resolution in seconds of the clock. time.monotonic() Monotonic clock, i.e. cannot go backward. It is not affected by system clock updates. The reference point of the returned value is undefined, so that only the difference between the results of consecutive calls is valid and is a nu...