id int64 0 190k | prompt stringlengths 21 13.4M | docstring stringlengths 1 12k ⌀ |
|---|---|---|
187,410 | import codecs
class Codec(codecs.Codec):
def encode(self,input,errors='strict'):
def decode(self,input,errors='strict'):
class IncrementalEncoder(codecs.IncrementalEncoder):
def encode(self, input, final=False):
class IncrementalDecoder(codecs.IncrementalDecoder):
def decode(self, input, final=False... | null |
187,411 | import codecs
class Codec(codecs.Codec):
def encode(self,input,errors='strict'):
return codecs.charmap_encode(input,errors,encoding_table)
def decode(self,input,errors='strict'):
return codecs.charmap_decode(input,errors,decoding_table)
class IncrementalEncoder(codecs.IncrementalEncoder):
de... | null |
187,412 | import codecs
class Codec(codecs.Codec):
def encode(self,input,errors='strict'):
def decode(self,input,errors='strict'):
class IncrementalEncoder(codecs.IncrementalEncoder):
def encode(self, input, final=False):
class IncrementalDecoder(codecs.IncrementalDecoder):
def decode(self, input, final=False... | null |
187,428 | import codecs
import binascii
def hex_encode(input, errors='strict'):
def hex_decode(input, errors='strict'):
class IncrementalEncoder(codecs.IncrementalEncoder):
def encode(self, input, final=False):
class IncrementalDecoder(codecs.IncrementalDecoder):
def decode(self, input, final=False):
class StreamWriter... | null |
187,432 | import codecs
class Codec(codecs.Codec):
def encode(self, input, errors='strict'):
def decode(self, input, errors='strict'):
class IncrementalEncoder(codecs.IncrementalEncoder):
def encode(self, input, final=False):
class IncrementalDecoder(codecs.IncrementalDecoder):
def decode(self, input, final=F... | null |
187,435 | import codecs
class Codec(codecs.Codec):
def encode(self,input,errors='strict'):
def decode(self,input,errors='strict'):
class IncrementalEncoder(codecs.IncrementalEncoder):
def encode(self, input, final=False):
class IncrementalDecoder(codecs.IncrementalDecoder):
def decode(self, input, final=False... | null |
187,439 | import codecs
class Codec(codecs.Codec):
def encode(self,input,errors='strict'):
def decode(self,input,errors='strict'):
class IncrementalEncoder(codecs.IncrementalEncoder):
def encode(self, input, final=False):
class IncrementalDecoder(codecs.IncrementalDecoder):
def decode(self, input, final=False... | null |
187,444 | import codecs
class Codec(codecs.Codec):
class IncrementalEncoder(codecs.IncrementalEncoder):
def encode(self, input, final=False):
class IncrementalDecoder(codecs.BufferedIncrementalDecoder):
def _buffer_decode(self, input, errors, final):
class StreamWriter(Codec,codecs.StreamWriter):
class StreamReader(Cod... | null |
187,447 | import codecs
class Codec(codecs.Codec):
def encode(self,input,errors='strict'):
return codecs.charmap_encode(input,errors,encoding_table)
def decode(self,input,errors='strict'):
return codecs.charmap_decode(input,errors,decoding_table)
class IncrementalEncoder(codecs.IncrementalEncoder):
de... | null |
187,462 | import codecs
class Codec(codecs.Codec):
def encode(self,input,errors='strict'):
def decode(self,input,errors='strict'):
class IncrementalEncoder(codecs.IncrementalEncoder):
def encode(self, input, final=False):
class IncrementalDecoder(codecs.IncrementalDecoder):
def decode(self, input, final=False... | null |
187,463 | import _io
import abc
from _io import (DEFAULT_BUFFER_SIZE, BlockingIOError, UnsupportedOperation,
open, open_code, FileIO, BytesIO, StringIO, BufferedReader,
BufferedWriter, BufferedRWPair, BufferedRandom,
IncrementalNewlineDecoder, text_encoding, TextIOWrapper)
def ... | null |
187,478 | from abc import get_cache_token
from collections import namedtuple
from reprlib import recursive_repr
from _thread import RLock
from types import GenericAlias
def update_wrapper(wrapper,
wrapped,
assigned = WRAPPER_ASSIGNMENTS,
updated = WRAPPER_UPDATES):
"""... | Single-dispatch generic function decorator. Transforms a function into a generic function, which can have different behaviours depending upon the type of its first argument. The decorated function acts as the default implementation, and additional implementations can be registered using the register() attribute of the ... |
187,481 | from builtins import open as bltn_open
import sys
import os
import io
import shutil
import stat
import time
import struct
import copy
import re
NUL = b"\0"
GNU_FORMAT = 1
DEFAULT_FORMAT = PAX_FORMAT
The provided code snippet includes n... | Convert a python number to a number field. |
187,488 | import os
import io
import re
import sys
import cmd
import bdb
import dis
import code
import glob
import pprint
import signal
import inspect
import tokenize
import traceback
import linecache
class Pdb(bdb.Bdb, cmd.Cmd):
_previous_sigint_handler = None
def __init__(self, completekey='tab', stdin=None, stdout=Non... | null |
187,491 | import os
import io
import re
import sys
import cmd
import bdb
import dis
import code
import glob
import pprint
import signal
import inspect
import tokenize
import traceback
import linecache
class Pdb(bdb.Bdb, cmd.Cmd):
_previous_sigint_handler = None
def __init__(self, completekey='tab', stdin=None, stdout=Non... | null |
187,498 | from abc import ABCMeta, abstractmethod
import sys
__name__ = "collections.abc"
def _is_typevarlike(arg):
obj = type(arg)
# looks like a TypeVar/ParamSpec
return (obj.__module__ == 'typing'
and obj.__name__ in {'ParamSpec', 'TypeVar'}) | null |
187,499 | from abc import ABCMeta, abstractmethod
import sys
__name__ = "collections.abc"
The provided code snippet includes necessary dependencies for implementing the `_is_param_expr` function. Write a Python function `def _is_param_expr(obj)` to solve the following problem:
Checks if obj matches either a list of types, ``...... | Checks if obj matches either a list of types, ``...``, ``ParamSpec`` or ``_ConcatenateGenericAlias`` from typing.py |
187,509 | import binascii
import importlib.util
import io
import itertools
import os
import posixpath
import shutil
import stat
import struct
import sys
import threading
import time
import contextlib
import pathlib
_EXTRA_FIELD_STRUCT = struct.Struct('<HH')
def _strip_extra(extra, xids):
# Remove Extra Fields with specified... | null |
187,510 | import binascii
import importlib.util
import io
import itertools
import os
import posixpath
import shutil
import stat
import struct
import sys
import threading
import time
import contextlib
import pathlib
_crctable = None
def _gen_crc(crc):
def _ZipDecrypter(pwd):
key0 = 305419896
key1 = 591751049
key2 = 8... | null |
187,511 | import binascii
import importlib.util
import io
import itertools
import os
import posixpath
import shutil
import stat
import struct
import sys
import threading
import time
import contextlib
import pathlib
try:
import zlib # We may need its compression method
crc32 = zlib.crc32
except ImportError:
zlib = Non... | null |
187,512 | import binascii
import importlib.util
import io
import itertools
import os
import posixpath
import shutil
import stat
import struct
import sys
import threading
import time
import contextlib
import pathlib
try:
import zlib # We may need its compression method
crc32 = zlib.crc32
except ImportError:
zlib = Non... | null |
187,513 | import binascii
import importlib.util
import io
import itertools
import os
import posixpath
import shutil
import stat
import struct
import sys
import threading
import time
import contextlib
import pathlib
def _ancestry(path):
"""
Given a path with elements separated by
posixpath.sep, generate all elements o... | Given a path with elements separated by posixpath.sep, generate all parents of that path. >>> list(_parents('b/d')) ['b'] >>> list(_parents('/b/d/')) ['/b'] >>> list(_parents('b/d/f/')) ['b/d', 'b'] >>> list(_parents('b')) [] >>> list(_parents('')) [] |
187,514 | import binascii
import importlib.util
import io
import itertools
import os
import posixpath
import shutil
import stat
import struct
import sys
import threading
import time
import contextlib
import pathlib
The provided code snippet includes necessary dependencies for implementing the `_difference` function. Write a Pyt... | Return items in minuend not in subtrahend, retaining order with O(1) lookup. |
187,522 | import sys
import os
from collections import namedtuple
from enum import Enum as _Enum, IntEnum as _IntEnum, IntFlag as _IntFlag
import _ssl
from _ssl import OPENSSL_VERSION_NUMBER, OPENSSL_VERSION_INFO, OPENSSL_VERSION
from _ssl import _SSLContext, MemoryBIO, SSLSession
from _ssl import (
SSLError, SSL... | Verify that *cert* (in decoded format as returned by SSLSocket.getpeercert()) matches the *hostname*. RFC 2818 and RFC 6125 rules are followed. The function matches IP addresses rather than dNSNames if hostname is a valid ipaddress string. IPv4 addresses are supported on all platforms. IPv6 addresses are supported on p... |
187,523 | import sys
import os
from collections import namedtuple
from enum import Enum as _Enum, IntEnum as _IntEnum, IntFlag as _IntFlag
import _ssl
from _ssl import OPENSSL_VERSION_NUMBER, OPENSSL_VERSION_INFO, OPENSSL_VERSION
from _ssl import _SSLContext, MemoryBIO, SSLSession
from _ssl import (
SSLError, SSL... | Return paths to default cafile and capath. |
187,524 | import sys
import os
from collections import namedtuple
from enum import Enum as _Enum, IntEnum as _IntEnum, IntFlag as _IntFlag
import _ssl
from _ssl import OPENSSL_VERSION_NUMBER, OPENSSL_VERSION_INFO, OPENSSL_VERSION
from _ssl import _SSLContext, MemoryBIO, SSLSession
from _ssl import (
SSLError, SSL... | Create a SSLContext object with default settings. NOTE: The protocol and settings may change anytime without prior deprecation. The values represent a fair balance between maximum compatibility and security. |
187,525 | import sys
import os
from collections import namedtuple
from enum import Enum as _Enum, IntEnum as _IntEnum, IntFlag as _IntFlag
import _ssl
from _ssl import OPENSSL_VERSION_NUMBER, OPENSSL_VERSION_INFO, OPENSSL_VERSION
from _ssl import _SSLContext, MemoryBIO, SSLSession
from _ssl import (
SSLError, SSL... | Create a SSLContext object for Python stdlib modules All Python stdlib modules shall use this function to create SSLContext objects in order to keep common settings in one place. The configuration is less restrict than create_default_context()'s to increase backward compatibility. |
187,526 | import sys
import os
from collections import namedtuple
from enum import Enum as _Enum, IntEnum as _IntEnum, IntFlag as _IntFlag
import _ssl
from _ssl import OPENSSL_VERSION_NUMBER, OPENSSL_VERSION_INFO, OPENSSL_VERSION
from _ssl import _SSLContext, MemoryBIO, SSLSession
from _ssl import (
SSLError, SSL... | Copy docstring from SSLObject to SSLSocket |
187,527 | import sys
import os
from collections import namedtuple
from enum import Enum as _Enum, IntEnum as _IntEnum, IntFlag as _IntFlag
import _ssl
from _ssl import OPENSSL_VERSION_NUMBER, OPENSSL_VERSION_INFO, OPENSSL_VERSION
from _ssl import _SSLContext, MemoryBIO, SSLSession
from _ssl import (
SSLError, SSL... | Return the time in seconds since the Epoch, given the timestring representing the "notBefore" or "notAfter" date from a certificate in ``"%b %d %H:%M:%S %Y %Z"`` strptime format (C locale). "notBefore" or "notAfter" dates must use UTC (RFC 5280). Month is one of: Jan Feb Mar Apr May Jun Jul Aug Sep Oct Nov Dec UTC shou... |
187,528 | import sys
import os
from collections import namedtuple
from enum import Enum as _Enum, IntEnum as _IntEnum, IntFlag as _IntFlag
import _ssl
from _ssl import OPENSSL_VERSION_NUMBER, OPENSSL_VERSION_INFO, OPENSSL_VERSION
from _ssl import _SSLContext, MemoryBIO, SSLSession
from _ssl import (
SSLError, SSL... | Takes a certificate in ASCII PEM format and returns the DER-encoded version of it as a byte sequence |
187,529 | import sys
import os
from collections import namedtuple
from enum import Enum as _Enum, IntEnum as _IntEnum, IntFlag as _IntFlag
import _ssl
from _ssl import OPENSSL_VERSION_NUMBER, OPENSSL_VERSION_INFO, OPENSSL_VERSION
from _ssl import _SSLContext, MemoryBIO, SSLSession
from _ssl import (
SSLError, SSL... | Retrieve the certificate from the server at the specified address, and return it as a PEM-encoded string. If 'ca_certs' is specified, validate the server cert against it. If 'ssl_version' is specified, use it in the connection attempt. If 'timeout' is specified, use it in the connection attempt. |
187,530 | import sys
import os
from collections import namedtuple
from enum import Enum as _Enum, IntEnum as _IntEnum, IntFlag as _IntFlag
import _ssl
from _ssl import OPENSSL_VERSION_NUMBER, OPENSSL_VERSION_INFO, OPENSSL_VERSION
from _ssl import _SSLContext, MemoryBIO, SSLSession
from _ssl import (
SSLError, SSL... | null |
187,532 | import abc
import sys
import _collections_abc
from collections import deque
from functools import wraps
from types import MethodType, GenericAlias
class _AsyncGeneratorContextManager(
_GeneratorContextManagerBase,
AbstractAsyncContextManager,
AsyncContextDecorator,
):
"""Helper for @asynccontextmanager ... | @asynccontextmanager decorator. Typical usage: @asynccontextmanager async def some_async_generator(<arguments>): <setup> try: yield <value> finally: <cleanup> This makes this: async with some_async_generator(<arguments>) as <variable>: <body> equivalent to this: <setup> try: <variable> = <value> <body> finally: <cleanu... |
187,536 | from _imp import (lock_held, acquire_lock, release_lock,
get_frozen_object, is_frozen_package,
init_frozen, is_builtin, is_frozen,
_fix_co_filename)
from importlib._bootstrap import _ERR_MSG, _exec, _load, _builtin_from_name
from importlib._bootstrap_external import... | **DEPRECATED** Given the path to a .py file, return the path to its .pyc file. The .py file does not need to exist; this simply returns the path to the .pyc file calculated as if the .py file were imported. If debug_override is not None, then it must be a boolean and is used in place of sys.flags.optimize. If sys.imple... |
187,552 | import math as _math
import numbers as _numbers
import sys
import contextvars
class Decimal(object):
"""Floating point class for decimal arithmetic."""
__slots__ = ('_exp','_int','_sign', '_is_special')
# Generally, the value of the Decimal instance is given by
# (-1)**_sign * _int * 10**_exp
# Spe... | Convert other to Decimal. Verifies that it's ok to use in an implicit construction. If allow_float is true, allow conversion from float; this is used in the comparison methods (__eq__ and friends). |
187,553 | import math as _math
import numbers as _numbers
import sys
class FloatOperation(DecimalException, TypeError):
"""Enable stricter semantics for mixing floats and Decimals.
If the signal is not trapped (default), mixing floats and Decimals is
permitted in the Decimal() constructor, context.create_decimal() an... | Given a Decimal instance self and a Python object other, return a pair (s, o) of Decimal instances such that "s op o" is equivalent to "self op other" for any of the 6 comparison operators "op". |
187,556 | from _sre import MAXREPEAT, MAXGROUPS
class _NamedIntConstant(int):
def __new__(cls, value, name):
self = super(_NamedIntConstant, cls).__new__(cls, value)
self.name = name
return self
def __repr__(self):
return self.name
__reduce__ = None
def _makecodes(names):
names = ... | null |
187,564 | from collections import namedtuple
from functools import singledispatch as simplegeneric
import importlib
import importlib.util
import importlib.machinery
import os
import os.path
import sys
from types import ModuleType
import warnings
def find_loader(fullname):
"""Find a "loader" object for fullname
This is a ... | Get a "loader" object for module_or_name Returns None if the module cannot be found or imported. If the named module is not already imported, its containing package (if any) is imported, in order to establish the package __path__. |
187,567 | from collections import namedtuple
from functools import singledispatch as simplegeneric
import importlib
import importlib.util
import importlib.machinery
import os
import os.path
import sys
from types import ModuleType
import warnings
_NAME_PATTERN = None
The provided code snippet includes necessary dependencies for ... | Resolve a name to an object. It is expected that `name` will be a string in one of the following formats, where W is shorthand for a valid Python identifier and dot stands for a literal period in these pseudo-regexes: W(.W)* W(.W)*:(W(.W)*)? The first form is intended for backward compatibility only. It assumes that so... |
187,568 | import io
import sys, os
from types import GenericAlias
_state = None
The provided code snippet includes necessary dependencies for implementing the `close` function. Write a Python function `def close()` to solve the following problem:
Close the sequence.
Here is the function:
def close():
"""Close the sequence... | Close the sequence. |
187,569 | import io
import sys, os
from types import GenericAlias
_state = None
The provided code snippet includes necessary dependencies for implementing the `nextfile` function. Write a Python function `def nextfile()` to solve the following problem:
Close the current file so that the next iteration will read the first line f... | Close the current file so that the next iteration will read the first line from the next file (if any); lines not read from the file will not count towards the cumulative line count. The filename is not changed until after the first line of the next file has been read. Before the first line has been read, this function... |
187,570 | import io
import sys, os
from types import GenericAlias
_state = None
The provided code snippet includes necessary dependencies for implementing the `fileno` function. Write a Python function `def fileno()` to solve the following problem:
Return the file number of the current file. When no file is currently opened, re... | Return the file number of the current file. When no file is currently opened, returns -1. |
187,571 | import io
import sys, os
from types import GenericAlias
_state = None
The provided code snippet includes necessary dependencies for implementing the `isstdin` function. Write a Python function `def isstdin()` to solve the following problem:
Returns true if the last line was read from sys.stdin, otherwise returns false... | Returns true if the last line was read from sys.stdin, otherwise returns false. |
187,572 | import io
import sys, os
from types import GenericAlias
from os.path import (curdir, pardir, sep, pathsep, defpath, extsep, altsep,
devnull)
def hook_compressed(filename, mode, *, encoding=None, errors=None):
if encoding is None: # EncodingWarning is emitted in FileInput() already.
encoding = "locale... | null |
187,573 | import io
import sys, os
from types import GenericAlias
def filename():
"""
Return the name of the file currently being read.
Before the first line has been read, returns None.
"""
if not _state:
raise RuntimeError("no active input()")
return _state.filename()
def hook_encoded(encoding,... | null |
187,574 | import io
import sys, os
from types import GenericAlias
def input(files=None, inplace=False, backup="", *, mode="r", openhook=None,
encoding=None, errors=None):
"""Return an instance of the FileInput class, which can be iterated.
The parameters are passed to the constructor of the FileInput class.
... | null |
187,623 | def _ctoi(c):
if type(c) == type(""):
return ord(c)
else:
return c
def isblank(c): return _ctoi(c) in (9, 32) | null |
187,624 | def _ctoi(c):
def iscntrl(c): return 0 <= _ctoi(c) <= 31 or _ctoi(c) == 127 | null |
187,632 | def _ctoi(c):
def alt(c):
if type(c) == type(""):
return chr(_ctoi(c) | 0x80)
else:
return _ctoi(c) | 0x80 | null |
187,638 | import re
import sys
import copy
import types
import inspect
import keyword
import builtins
import functools
import abc
import _thread
from types import FunctionType, GenericAlias
def _hash_set_none(cls, fields, globals):
return None | null |
187,639 | import re
import sys
import copy
import types
import inspect
import keyword
import builtins
import functools
import abc
import _thread
from types import FunctionType, GenericAlias
def _hash_fn(fields, globals):
self_tuple = _tuple_str('self', fields)
return _create_fn('__hash__',
('self',)... | null |
187,640 | import re
import sys
import copy
import types
import inspect
import keyword
import builtins
import functools
import abc
import _thread
from types import FunctionType, GenericAlias
def _hash_exception(cls, fields, globals):
# Raise an exception.
raise TypeError(f'Cannot overwrite attribute __hash__ '
... | null |
187,641 | import re
import sys
import copy
import types
import inspect
import keyword
import builtins
import functools
import abc
import _thread
from types import FunctionType, GenericAlias
_FIELDS = '__dataclass_fields__'
GenericAlias = type(list[int])
The provided code snippet includes necessary dependencies for implementing... | Returns True if obj is a dataclass or an instance of a dataclass. |
187,642 | import re
import sys
import copy
import types
import inspect
import keyword
import builtins
import functools
import abc
import _thread
from types import FunctionType, GenericAlias
def _is_dataclass_instance(obj):
"""Returns True if obj is an instance of a dataclass."""
return hasattr(type(obj), _FIELDS)
def _as... | Return the fields of a dataclass instance as a new dictionary mapping field names to field values. Example usage: @dataclass class C: x: int y: int c = C(1, 2) assert asdict(c) == {'x': 1, 'y': 2} If given, 'dict_factory' will be used instead of built-in dict. The function applies recursively to field values that are d... |
187,643 | import re
import sys
import copy
import types
import inspect
import keyword
import builtins
import functools
import abc
import _thread
from types import FunctionType, GenericAlias
def _is_dataclass_instance(obj):
"""Returns True if obj is an instance of a dataclass."""
return hasattr(type(obj), _FIELDS)
def _as... | Return the fields of a dataclass instance as a new tuple of field values. Example usage:: @dataclass class C: x: int y: int c = C(1, 2) assert astuple(c) == (1, 2) If given, 'tuple_factory' will be used instead of built-in tuple. The function applies recursively to field values that are dataclass instances. This will a... |
187,644 | import re
import sys
import copy
import types
import inspect
import keyword
import builtins
import functools
import abc
import _thread
from types import FunctionType, GenericAlias
def dataclass(cls=None, /, *, init=True, repr=True, eq=True, order=False,
unsafe_hash=False, frozen=False, match_args=True,
... | Return a new dynamically created dataclass. The dataclass name will be 'cls_name'. 'fields' is an iterable of either (name), (name, type) or (name, type, Field) objects. If type is omitted, use the string 'typing.Any'. Field objects are created by the equivalent of calling 'field(name, type [, Field-info])'. C = make_d... |
187,656 | import concurrent.futures
import contextvars
import logging
import sys
from types import GenericAlias
from . import base_futures
from . import events
from . import exceptions
from . import format_helpers
isfuture = base_futures.isfuture
class Future:
"""This class is *almost* compatible with concurrent.futures.Futu... | Wrap concurrent.futures.Future object. |
187,657 | import subprocess
from . import events
from . import protocols
from . import streams
from . import tasks
from .log import logger
class SubprocessStreamProtocol(streams.FlowControlMixin,
protocols.SubprocessProtocol):
"""Like StreamReaderProtocol, but for a subprocess."""
def __ini... | null |
187,658 | import subprocess
from . import events
from . import protocols
from . import streams
from . import tasks
from .log import logger
class SubprocessStreamProtocol(streams.FlowControlMixin,
protocols.SubprocessProtocol):
"""Like StreamReaderProtocol, but for a subprocess."""
def __ini... | null |
187,669 | import collections
import collections.abc
import concurrent.futures
import functools
import heapq
import itertools
import os
import socket
import stat
import subprocess
import threading
import time
import traceback
import sys
import warnings
import weakref
try:
import ssl
except ImportError: # pragma: no cover
... | null |
187,671 | import concurrent.futures
import contextvars
import functools
import inspect
import itertools
import types
import warnings
import weakref
from types import GenericAlias
from . import base_tasks
from . import coroutines
from . import events
from . import exceptions
from . import futures
from .coroutines import _is_corou... | Return an iterator whose values are coroutines. When waiting for the yielded coroutines you'll get the results (or exceptions!) of the original Futures (or coroutines), in the order in which and as soon as they complete. This differs from PEP 3148; the proper way to use this is: for f in as_completed(fs): result = awai... |
187,672 | import concurrent.futures
import contextvars
import functools
import inspect
import itertools
import types
import warnings
import weakref
from types import GenericAlias
from . import base_tasks
from . import coroutines
from . import events
from . import exceptions
from . import futures
from .coroutines import _is_corou... | Coroutine that completes after a given time (in seconds). |
187,673 | import concurrent.futures
import contextvars
import functools
import inspect
import itertools
import types
import warnings
import weakref
from types import GenericAlias
from . import base_tasks
from . import coroutines
from . import events
from . import exceptions
from . import futures
from .coroutines import _is_corou... | null |
187,674 | import concurrent.futures
import contextvars
import functools
import inspect
import itertools
import types
import warnings
import weakref
from types import GenericAlias
from . import base_tasks
from . import coroutines
from . import events
from . import exceptions
from . import futures
from .coroutines import _is_corou... | Wait for a future, shielding it from cancellation. The statement res = await shield(something()) is exactly equivalent to the statement res = await something() *except* that if the coroutine containing it is cancelled, the task running in something() is not cancelled. From the POV of something(), the cancellation did n... |
187,675 | import concurrent.futures
import contextvars
import functools
import inspect
import itertools
import types
import warnings
import weakref
from types import GenericAlias
from . import base_tasks
from . import coroutines
from . import events
from . import exceptions
from . import futures
from .coroutines import _is_corou... | Submit a coroutine object to a given event loop. Return a concurrent.futures.Future to access the result. |
187,676 | import concurrent.futures
import contextvars
import functools
import inspect
import itertools
import types
import warnings
import weakref
from types import GenericAlias
from . import base_tasks
from . import coroutines
from . import events
from . import exceptions
from . import futures
from .coroutines import _is_corou... | Register a new task in asyncio as executed by loop. |
187,677 | import concurrent.futures
import contextvars
import functools
import inspect
import itertools
import types
import warnings
import weakref
from types import GenericAlias
from . import base_tasks
from . import coroutines
from . import events
from . import exceptions
from . import futures
from .coroutines import _is_corou... | null |
187,678 | import concurrent.futures
import contextvars
import functools
import inspect
import itertools
import types
import warnings
import weakref
from types import GenericAlias
from . import base_tasks
from . import coroutines
from . import events
from . import exceptions
from . import futures
from .coroutines import _is_corou... | null |
187,679 | import concurrent.futures
import contextvars
import functools
import inspect
import itertools
import types
import warnings
import weakref
from types import GenericAlias
from . import base_tasks
from . import coroutines
from . import events
from . import exceptions
from . import futures
from .coroutines import _is_corou... | Unregister a task. |
187,683 | from . import coroutines
from . import events
from . import tasks
def _cancel_all_tasks(loop):
to_cancel = tasks.all_tasks(loop)
if not to_cancel:
return
for task in to_cancel:
task.cancel()
loop.run_until_complete(tasks.gather(*to_cancel, return_exceptions=True))
for task in to_canc... | Execute the coroutine and return the result. This function runs the passed coroutine, taking care of managing the asyncio event loop and finalizing asynchronous generators. This function cannot be called when another asyncio event loop is running in the same thread. If debug is True, the event loop will be run in debug... |
187,685 | import errno
import io
import itertools
import os
import selectors
import signal
import socket
import stat
import subprocess
import sys
import threading
import warnings
from . import base_events
from . import base_subprocess
from . import constants
from . import coroutines
from . import events
from . import exceptions
... | null |
187,686 | import socket
import sys
import warnings
import weakref
from . import coroutines
from . import events
from . import exceptions
from . import format_helpers
from . import protocols
from .log import logger
from .tasks import sleep
_DEFAULT_LIMIT = 2 ** 16
class StreamReaderProtocol(FlowControlMixin, protocols.Protocol):... | A wrapper for create_connection() returning a (reader, writer) pair. The reader returned is a StreamReader instance; the writer is a StreamWriter instance. The arguments are all the usual arguments to create_connection() except protocol_factory; most common are positional host and port, with various optional keyword ar... |
187,687 | import socket
import sys
import warnings
import weakref
from . import coroutines
from . import events
from . import exceptions
from . import format_helpers
from . import protocols
from .log import logger
from .tasks import sleep
_DEFAULT_LIMIT = 2 ** 16
class StreamReaderProtocol(FlowControlMixin, protocols.Protocol):... | Start a socket server, call back for each client connected. The first parameter, `client_connected_cb`, takes two parameters: client_reader, client_writer. client_reader is a StreamReader object, while client_writer is a StreamWriter object. This parameter can either be a plain callback function or a coroutine; if it i... |
187,688 | import socket
import sys
import warnings
import weakref
from . import coroutines
from . import events
from . import exceptions
from . import format_helpers
from . import protocols
from .log import logger
from .tasks import sleep
_DEFAULT_LIMIT = 2 ** 16
class StreamReaderProtocol(FlowControlMixin, protocols.Protocol):... | Similar to `open_connection` but works with UNIX Domain Sockets. |
187,689 | import socket
import sys
import warnings
import weakref
from . import coroutines
from . import events
from . import exceptions
from . import format_helpers
from . import protocols
from .log import logger
from .tasks import sleep
_DEFAULT_LIMIT = 2 ** 16
class StreamReaderProtocol(FlowControlMixin, protocols.Protocol):... | Similar to `start_server` but works with UNIX Domain Sockets. |
187,694 | import reprlib
from _thread import get_ident
from . import format_helpers
def jit_suppress(f):
return f | null |
187,695 | import reprlib
from _thread import get_ident
from . import format_helpers
async def _asyncio_async_lazy_value_metadata_entrypoint_(alv, f, *args, **kwargs):
try:
alv._link()
return await f(*args, **kwargs)
finally:
alv._unlink() | null |
187,708 | import contextlib
import os
import re
import fnmatch
import itertools
import stat
import sys
def _glob0(dirname, basename, dir_fd, dironly):
if basename:
if _lexists(_join(dirname, basename), dir_fd):
return [basename]
else:
# `os.path.split()` returns an empty basename for paths end... | null |
187,709 | import contextlib
import os
import re
import fnmatch
import itertools
import stat
import sys
def _glob1(dirname, pattern, dir_fd, dironly):
names = _listdir(dirname, dir_fd, dironly)
if not _ishidden(pattern):
names = (x for x in names if not _ishidden(x))
return fnmatch.filter(names, pattern)
def ... | null |
187,713 | import os
import sys
import stat
import genericpath
from genericpath import *
def _get_bothseps(path):
if isinstance(path, bytes):
return b'\\/'
else:
return '\\/'
def join(path, *paths):
path = os.fspath(path)
if isinstance(path, bytes):
sep = b'\\'
seps = b'\\/'
... | Expand ~ and ~user constructs. If user or $HOME is unknown, do nothing. |
187,715 | devnull = 'nul'
import os
import sys
import stat
import genericpath
from genericpath import *
def normcase(s):
def isabs(s):
def join(path, *paths):
def normpath(path):
try:
from nt import _getfinalpathname, readlink as _nt_readlink
except ImportError:
# realpath is a no-op on systems without _getfinalpathname ... | null |
187,721 | import os
import sys
import copy
from subprocess import Popen, PIPE, check_output
import re
from distutils.unixccompiler import UnixCCompiler
from distutils.file_util import write_file
from distutils.errors import (DistutilsExecError, CCompilerError,
CompileError, UnknownFileError)
from distutils.version import... | Check if the current Python installation appears amenable to building extensions with GCC. Returns a tuple (status, details), where 'status' is one of the following constants: - CONFIG_H_OK: all is well, go ahead and compile - CONFIG_H_NOTOK: doesn't look good - CONFIG_H_UNCERTAIN: not sure -- unable to read pyconfig.h... |
187,730 | import os
import re
import importlib.util
import string
import sys
import distutils
from distutils.errors import DistutilsPlatformError
from distutils.dep_util import newer
from distutils.spawn import spawn
from distutils import log
from distutils.errors import DistutilsByteCompileError
The provided code snippet inclu... | Return 'pathname' as a name that will work on the native filesystem, i.e. split it on '/' and put it back together again using the current directory separator. Needed because filenames in the setup script are always supplied in Unix style, and have to be converted to the local convention before we can actually use them... |
187,731 | import os
import re
import importlib.util
import string
import sys
import distutils
from distutils.errors import DistutilsPlatformError
from distutils.dep_util import newer
from distutils.spawn import spawn
from distutils import log
from distutils.errors import DistutilsByteCompileError
class DistutilsPlatformError (D... | Return 'pathname' with 'new_root' prepended. If 'pathname' is relative, this is equivalent to "os.path.join(new_root,pathname)". Otherwise, it requires making 'pathname' relative and then joining the two, which is tricky on DOS/Windows and Mac OS. |
187,732 | import os
import re
import importlib.util
import string
import sys
import distutils
from distutils.errors import DistutilsPlatformError
from distutils.dep_util import newer
from distutils.spawn import spawn
from distutils import log
from distutils.errors import DistutilsByteCompileError
def check_environ ():
"""Ens... | Perform shell/Perl-style variable substitution on 'string'. Every occurrence of '$' followed by a name is considered a variable, and variable is substituted by the value found in the 'local_vars' dictionary, or in 'os.environ' if it's not in 'local_vars'. 'os.environ' is first checked/augmented to guarantee that it con... |
187,733 | import os
import re
import importlib.util
import string
import sys
import distutils
from distutils.errors import DistutilsPlatformError
from distutils.dep_util import newer
from distutils.spawn import spawn
from distutils import log
from distutils.errors import DistutilsByteCompileError
def grok_environment_error (exc... | null |
187,734 | import os
import re
import importlib.util
import string
import sys
import distutils
from distutils.errors import DistutilsPlatformError
from distutils.dep_util import newer
from distutils.spawn import spawn
from distutils import log
from distutils.errors import DistutilsByteCompileError
The provided code snippet inclu... | Convert a string representation of truth to true (1) or false (0). True values are 'y', 'yes', 't', 'true', 'on', and '1'; false values are 'n', 'no', 'f', 'false', 'off', and '0'. Raises ValueError if 'val' is anything else. |
187,735 | import os
import re
import importlib.util
import string
import sys
import distutils
from distutils.errors import DistutilsPlatformError
from distutils.dep_util import newer
from distutils.spawn import spawn
from distutils import log
from distutils.errors import DistutilsByteCompileError
def execute (func, args, msg=Non... | Byte-compile a collection of Python source files to .pyc files in a __pycache__ subdirectory. 'py_files' is a list of files to compile; any files that don't end in ".py" are silently skipped. 'optimize' must be one of the following: 0 - don't optimize 1 - normal optimization (like "python -O") 2 - extra optimization (l... |
187,736 | import os
import re
import importlib.util
import string
import sys
import distutils
from distutils.errors import DistutilsPlatformError
from distutils.dep_util import newer
from distutils.spawn import spawn
from distutils import log
from distutils.errors import DistutilsByteCompileError
The provided code snippet inclu... | Return a version of the string escaped for inclusion in an RFC-822 header, by ensuring there are 8 spaces space after each newline. |
187,737 | import os
import re
import importlib.util
import string
import sys
import distutils
from distutils.errors import DistutilsPlatformError
from distutils.dep_util import newer
from distutils.spawn import spawn
from distutils import log
from distutils.errors import DistutilsByteCompileError
def run_2to3(files, fixer_names=... | Recursively copy a directory, only copying new and changed files, running run_2to3 over all newly copied Python modules afterward. If you give a template string, it's parsed like a MANIFEST.in. |
187,744 | import os
from distutils.core import Command
from distutils.errors import *
from distutils.util import get_platform
class bdist(Command):
description = "create a built (binary) distribution"
user_options = [('bdist-base=', 'b',
"temporary directory for creating built distributions"),
... | Print list of available formats (arguments to "--format" option). |
187,757 | import _imp
import os
import re
import sys
import warnings
from functools import partial
from .errors import DistutilsPlatformError
from sysconfig import (
_PREFIX as PREFIX,
_BASE_PREFIX as BASE_PREFIX,
_EXEC_PREFIX as EXEC_PREFIX,
_BASE_EXEC_PREFIX as BASE_EXEC_PREFIX,
_PROJECT_BASE as project_bas... | null |
187,758 | import _imp
import os
import re
import sys
import warnings
from functools import partial
from .errors import DistutilsPlatformError
from sysconfig import (
_PREFIX as PREFIX,
_BASE_PREFIX as BASE_PREFIX,
_EXEC_PREFIX as EXEC_PREFIX,
_BASE_EXEC_PREFIX as BASE_EXEC_PREFIX,
_PROJECT_BASE as project_bas... | Do any platform-specific customization of a CCompiler instance. Mainly needed on Unix, so we can plug in the information that varies across Unices and is stored in Python's Makefile. |
187,759 | import _imp
import os
import re
import sys
import warnings
from functools import partial
from .errors import DistutilsPlatformError
from sysconfig import (
_PREFIX as PREFIX,
_BASE_PREFIX as BASE_PREFIX,
_EXEC_PREFIX as EXEC_PREFIX,
_BASE_EXEC_PREFIX as BASE_EXEC_PREFIX,
_PROJECT_BASE as project_bas... | Return the directory containing installed Python header files. If 'plat_specific' is false (the default), this is the path to the non-platform-specific header files, i.e. Python.h and so on; otherwise, this is the path to platform-specific header files (namely pyconfig.h). If 'prefix' is supplied, use it instead of sys... |
187,760 | import _imp
import os
import re
import sys
import warnings
from functools import partial
from .errors import DistutilsPlatformError
from sysconfig import (
_PREFIX as PREFIX,
_BASE_PREFIX as BASE_PREFIX,
_EXEC_PREFIX as EXEC_PREFIX,
_BASE_EXEC_PREFIX as BASE_EXEC_PREFIX,
_PROJECT_BASE as project_bas... | Return the directory containing the Python library (standard or site additions). If 'plat_specific' is true, return the directory containing platform-specific modules, i.e. any module from a non-pure-Python module distribution; otherwise, return the platform-shared library directory. If 'standard_lib' is true, return t... |
187,763 | import os
import re
import warnings
class Extension:
"""Just a collection of attributes that describes an extension
module and everything needed to build it (hopefully in a portable
way, but there are hooks that let you be as unportable as you need).
Instance attributes:
name : string
the ... | Reads a Setup file and returns Extension instances. |
187,778 | import math
import numbers
import random
from fractions import Fraction
from decimal import Decimal
from itertools import groupby, repeat
from bisect import bisect_left, bisect_right
from math import hypot, sqrt, fabs, exp, erf, tau, log, fsum
from operator import itemgetter
from collections import Counter, namedtuple
... | Convert data to floats and compute the geometric mean. Raises a StatisticsError if the input dataset is empty, if it contains a zero, or if it contains a negative value. No special efforts are made to achieve exact results. (However, this may change in the future.) >>> round(geometric_mean([54, 24, 36]), 9) 36.0 |
187,779 | import math
import numbers
import random
from fractions import Fraction
from decimal import Decimal
from itertools import groupby, repeat
from bisect import bisect_left, bisect_right
from math import hypot, sqrt, fabs, exp, erf, tau, log, fsum
from operator import itemgetter
from collections import Counter, namedtuple
... | Return the harmonic mean of data. The harmonic mean is the reciprocal of the arithmetic mean of the reciprocals of the data. It can be used for averaging ratios or rates, for example speeds. Suppose a car travels 40 km/hr for 5 km and then speeds-up to 60 km/hr for another 5 km. What is the average speed? >>> harmonic_... |
187,780 | import math
import numbers
import random
from fractions import Fraction
from decimal import Decimal
from itertools import groupby, repeat
from bisect import bisect_left, bisect_right
from math import hypot, sqrt, fabs, exp, erf, tau, log, fsum
from operator import itemgetter
from collections import Counter, namedtuple
... | Return the median (middle value) of numeric data. When the number of data points is odd, return the middle data point. When the number of data points is even, the median is interpolated by taking the average of the two middle values: >>> median([1, 3, 5]) 3 >>> median([1, 3, 5, 7]) 4.0 |
187,781 | import math
import numbers
import random
from fractions import Fraction
from decimal import Decimal
from itertools import groupby, repeat
from bisect import bisect_left, bisect_right
from math import hypot, sqrt, fabs, exp, erf, tau, log, fsum
from operator import itemgetter
from collections import Counter, namedtuple
... | Return the low median of numeric data. When the number of data points is odd, the middle value is returned. When it is even, the smaller of the two middle values is returned. >>> median_low([1, 3, 5]) 3 >>> median_low([1, 3, 5, 7]) 3 |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.