source stringclasses 1 value | version stringclasses 1 value | module stringclasses 43 values | function stringclasses 307 values | input stringlengths 3 496 | expected stringlengths 0 40.5k | signature stringclasses 0 values |
|---|---|---|---|---|---|---|
cpython | cfcd524 | importlib.metadata | EntryPoint | >>> EntryPoint(name=None, group=None, value='invalid-name').attr | Traceback (most recent call last):
...
ValueError: ('Invalid object reference...invalid-name... | null |
cpython | cfcd524 | importlib.metadata | EntryPoint | >>> EntryPoint(name=None, group=None, value='invalid-name').extras | Traceback (most recent call last):
...
ValueError: ('Invalid object reference...invalid-name...
The same thing happens on construction. | null |
cpython | cfcd524 | importlib.metadata | EntryPoint | >>> EntryPoint(name=None, group=None, value='invalid-name') | Traceback (most recent call last):
...
ValueError: ('Invalid object reference...invalid-name... | null |
cpython | cfcd524 | importlib.metadata | EntryPoint.matches | >>> ep = EntryPoint(group='foo', name='bar', value='bing:bong [extra1, extra2]') | null | |
cpython | cfcd524 | importlib.metadata | EntryPoint.matches | >>> ep.matches(group='foo') | True | null |
cpython | cfcd524 | importlib.metadata | EntryPoint.matches | >>> ep.matches(name='bar', value='bing:bong [extra1, extra2]') | True | null |
cpython | cfcd524 | importlib.metadata | EntryPoint.matches | >>> ep.matches(group='foo', name='other') | False | null |
cpython | cfcd524 | importlib.metadata | EntryPoint.matches | >>> ep.matches() | True | null |
cpython | cfcd524 | importlib.metadata | EntryPoint.matches | >>> ep.matches(extras=['extra1', 'extra2']) | True | null |
cpython | cfcd524 | importlib.metadata | EntryPoint.matches | >>> ep.matches(module='bing') | True | null |
cpython | cfcd524 | importlib.metadata | EntryPoint.matches | >>> ep.matches(attr='bong') | True | null |
cpython | cfcd524 | importlib.metadata | EntryPoint._disallow_dist | >>> EntryPoint(name='fan', value='fav', group='fag').matches(dist='foo') | Traceback (most recent call last):
...
ValueError: "dist" is not suitable for matching... | null |
cpython | cfcd524 | importlib.metadata | FastPath | >>> FastPath('').children() | ['...']
FastPath objects are cached and recycled for any given root. | null |
cpython | cfcd524 | importlib.metadata | FastPath | >>> FastPath('foobar') is FastPath('foobar') | True | null |
cpython | cfcd524 | importlib.metadata | Prepared | >>> none = Prepared(None) | null | |
cpython | cfcd524 | importlib.metadata | Prepared | >>> none.normalized | null | |
cpython | cfcd524 | importlib.metadata | Prepared | >>> none.legacy_normalized | null | |
cpython | cfcd524 | importlib.metadata | Prepared | >>> bool(none) | False | null |
cpython | cfcd524 | importlib.metadata | Prepared | >>> sample = Prepared('Sample__Pkg-name.foo') | null | |
cpython | cfcd524 | importlib.metadata | Prepared | >>> sample.normalized | 'sample_pkg_name_foo' | null |
cpython | cfcd524 | importlib.metadata | Prepared | >>> sample.legacy_normalized | 'sample__pkg_name.foo' | null |
cpython | cfcd524 | importlib.metadata | Prepared | >>> bool(sample) | True | null |
cpython | cfcd524 | importlib.metadata | PathDistribution._name_from_stem | >>> PathDistribution._name_from_stem('foo-3.0.egg-info') | 'foo' | null |
cpython | cfcd524 | importlib.metadata | PathDistribution._name_from_stem | >>> PathDistribution._name_from_stem('CherryPy-3.0.dist-info') | 'CherryPy' | null |
cpython | cfcd524 | importlib.metadata | PathDistribution._name_from_stem | >>> PathDistribution._name_from_stem('face.egg-info') | 'face' | null |
cpython | cfcd524 | importlib.metadata | PathDistribution._name_from_stem | >>> PathDistribution._name_from_stem('foo.bar') | null | |
cpython | cfcd524 | importlib.metadata | PathDistribution.packages_distributions | >>> import collections.abc | null | |
cpython | cfcd524 | importlib.metadata | PathDistribution.packages_distributions | >>> pkgs = packages_distributions() | null | |
cpython | cfcd524 | importlib.metadata | PathDistribution.packages_distributions | >>> all(isinstance(dist, collections.abc.Sequence) for dist in pkgs.values()) | True | null |
cpython | cfcd524 | importlib.metadata | PathDistribution._get_toplevel_name | >>> _get_toplevel_name(PackagePath('foo.py')) | 'foo' | null |
cpython | cfcd524 | importlib.metadata | PathDistribution._get_toplevel_name | >>> _get_toplevel_name(PackagePath('foo')) | 'foo' | null |
cpython | cfcd524 | importlib.metadata | PathDistribution._get_toplevel_name | >>> _get_toplevel_name(PackagePath('foo.pyc')) | 'foo' | null |
cpython | cfcd524 | importlib.metadata | PathDistribution._get_toplevel_name | >>> _get_toplevel_name(PackagePath('foo/__init__.py')) | 'foo' | null |
cpython | cfcd524 | importlib.metadata | PathDistribution._get_toplevel_name | >>> _get_toplevel_name(PackagePath('foo.pth')) | 'foo.pth' | null |
cpython | cfcd524 | importlib.metadata | PathDistribution._get_toplevel_name | >>> _get_toplevel_name(PackagePath('foo.dist-info')) | 'foo.dist-info' | null |
cpython | cfcd524 | importlib.metadata._adapters | Message | >>> msg_text = textwrap.dedent('''
... Name: Foo
... Version: 3.0
... License: blah
... de-blah
... <BLANKLINE>
... First line of description.
... Second line of description.
... <BLANKLINE>
... Fourth line!
... ''').lstrip().replace('<BLANKLINE>', '') | null | |
cpython | cfcd524 | importlib.metadata._adapters | Message | >>> msg = Message(email.message_from_string(msg_text)) | null | |
cpython | cfcd524 | importlib.metadata._adapters | Message | >>> msg['Description'] | 'First line of description.\nSecond line of description.\n\nFourth line!\n'
Message should render even if values contain newlines. | null |
cpython | cfcd524 | importlib.metadata._adapters | Message | >>> print(msg) | Name: Foo
Version: 3.0
License: blah
de-blah
Description: First line of description.
Second line of description.
<BLANKLINE>
Fourth line!
<BLANKLINE>
<BLANKLINE> | null |
cpython | cfcd524 | importlib.resources._itertools | only | >>> only([], default='missing') | 'missing' | null |
cpython | cfcd524 | importlib.resources._itertools | only | >>> only([1]) | 1 | null |
cpython | cfcd524 | importlib.resources._itertools | only | >>> only([1, 2]) # doctest: +IGNORE_EXCEPTION_DETAIL | Traceback (most recent call last):
...
ValueError: Expected exactly one item in iterable, but got 1, 2,
and perhaps more.' | null |
cpython | cfcd524 | importlib.resources._itertools | only | >>> only([1, 2], too_long=TypeError) # doctest: +IGNORE_EXCEPTION_DETAIL | Traceback (most recent call last):
...
TypeError
Note that :func:`only` attempts to advance *iterable* twice to ensure there
is only one item. See :func:`spy` or :func:`peekable` to check
iterable contents less destructively. | null |
cpython | cfcd524 | enum | member.bin | >>> bin(10) | '0b0 1010' | null |
cpython | cfcd524 | enum | member.bin | >>> bin(~10) # ~10 is -11 | '0b1 0101' | null |
cpython | cfcd524 | enum | Enum | >>> class Color(Enum):
... RED = 1
... BLUE = 2
... GREEN = 3 | Access them by:
- attribute access: | null |
cpython | cfcd524 | enum | Enum | >>> Color.RED | <Color.RED: 1>
- value lookup: | null |
cpython | cfcd524 | enum | Enum | >>> Color(1) | <Color.RED: 1>
- name lookup: | null |
cpython | cfcd524 | enum | Enum | >>> Color['RED'] | <Color.RED: 1>
Enumerations can be iterated over, and know how many members they have: | null |
cpython | cfcd524 | enum | Enum | >>> len(Color) | 3 | null |
cpython | cfcd524 | enum | Enum | >>> list(Color) | [<Color.RED: 1>, <Color.BLUE: 2>, <Color.GREEN: 3>]
Methods can be added to enumerations, and members can have their own
attributes -- see the documentation for details. | null |
cpython | cfcd524 | enum | IntFlag._simple_enum | >>> from enum import Enum, _simple_enum | null | |
cpython | cfcd524 | enum | IntFlag._simple_enum | >>> @_simple_enum(Enum)
... class Color:
... RED = auto()
... GREEN = auto()
... BLUE = auto() | null | |
cpython | cfcd524 | enum | IntFlag._simple_enum | >>> Color | <enum 'Color'> | null |
cpython | cfcd524 | enum | verify._test_simple_enum | >>> from enum import Enum, _simple_enum, _test_simple_enum | null | |
cpython | cfcd524 | enum | verify._test_simple_enum | >>> @_simple_enum(Enum)
... class Color:
... RED = auto()
... GREEN = auto()
... BLUE = auto() | null | |
cpython | cfcd524 | enum | verify._test_simple_enum | >>> class CheckedColor(Enum):
... RED = auto()
... GREEN = auto()
... BLUE = auto() | null | |
cpython | cfcd524 | enum | verify._test_simple_enum | >>> _test_simple_enum(CheckedColor, Color) | If differences are found, a :exc:`TypeError` is raised. | null |
cpython | cfcd524 | socket | SocketIO.create_server | >>> with create_server(('', 8000)) as server:
... while True:
... conn, addr = server.accept()
... # handle new connection | null | |
cpython | cfcd524 | http.cookies | __module__ | >>> from http import cookies | Most of the time you start by creating a cookie. | null |
cpython | cfcd524 | http.cookies | __module__ | >>> C = cookies.SimpleCookie() | Once you've created your Cookie, you can add values just as if it were
a dictionary. | null |
cpython | cfcd524 | http.cookies | __module__ | >>> C = cookies.SimpleCookie() | null | |
cpython | cfcd524 | http.cookies | __module__ | >>> C["fig"] = "newton" | null | |
cpython | cfcd524 | http.cookies | __module__ | >>> C["sugar"] = "wafer" | null | |
cpython | cfcd524 | http.cookies | __module__ | >>> C.output() | 'Set-Cookie: fig=newton\r\nSet-Cookie: sugar=wafer'
Notice that the printable representation of a Cookie is the
appropriate format for a Set-Cookie: header. This is the
default behavior. You can change the header and printed
attributes by using the .output() function | null |
cpython | cfcd524 | http.cookies | __module__ | >>> C = cookies.SimpleCookie() | null | |
cpython | cfcd524 | http.cookies | __module__ | >>> C["rocky"] = "road" | null | |
cpython | cfcd524 | http.cookies | __module__ | >>> C["rocky"]["path"] = "/cookie" | null | |
cpython | cfcd524 | http.cookies | __module__ | >>> print(C.output(header="Cookie:")) | Cookie: rocky=road; Path=/cookie | null |
cpython | cfcd524 | http.cookies | __module__ | >>> print(C.output(attrs=[], header="Cookie:")) | Cookie: rocky=road
The load() method of a Cookie extracts cookies from a string. In a
CGI script, you would use this method to extract the cookies from the
HTTP_COOKIE environment variable. | null |
cpython | cfcd524 | http.cookies | __module__ | >>> C = cookies.SimpleCookie() | null | |
cpython | cfcd524 | http.cookies | __module__ | >>> C.load("chips=ahoy; vienna=finger") | null | |
cpython | cfcd524 | http.cookies | __module__ | >>> C.output() | 'Set-Cookie: chips=ahoy\r\nSet-Cookie: vienna=finger'
The load() method is darn-tootin smart about identifying cookies
within a string. Escaped quotation marks, nested semicolons, and other
such trickeries do not confuse it. | null |
cpython | cfcd524 | http.cookies | __module__ | >>> C = cookies.SimpleCookie() | null | |
cpython | cfcd524 | http.cookies | __module__ | >>> C.load('keebler="E=everybody; L=\\"Loves\\"; fudge=\\012;";') | null | |
cpython | cfcd524 | http.cookies | __module__ | >>> print(C) | Set-Cookie: keebler="E=everybody; L=\"Loves\"; fudge=\012;"
Each element of the Cookie also supports all of the RFC 2109
Cookie attributes. Here's an example which sets the Path
attribute. | null |
cpython | cfcd524 | http.cookies | __module__ | >>> C = cookies.SimpleCookie() | null | |
cpython | cfcd524 | http.cookies | __module__ | >>> C["oreo"] = "doublestuff" | null | |
cpython | cfcd524 | http.cookies | __module__ | >>> C["oreo"]["path"] = "/" | null | |
cpython | cfcd524 | http.cookies | __module__ | >>> print(C) | Set-Cookie: oreo=doublestuff; Path=/
Each dictionary element has a 'value' attribute, which gives you
back the value associated with the key. | null |
cpython | cfcd524 | http.cookies | __module__ | >>> C = cookies.SimpleCookie() | null | |
cpython | cfcd524 | http.cookies | __module__ | >>> C["twix"] = "none for you" | null | |
cpython | cfcd524 | http.cookies | __module__ | >>> C["twix"].value | 'none for you'
The SimpleCookie expects that all values should be standard strings.
Just to be sure, SimpleCookie invokes the str() builtin to convert
the value to a string, when the values are set dictionary-style. | null |
cpython | cfcd524 | http.cookies | __module__ | >>> C = cookies.SimpleCookie() | null | |
cpython | cfcd524 | http.cookies | __module__ | >>> C["number"] = 7 | null | |
cpython | cfcd524 | http.cookies | __module__ | >>> C["string"] = "seven" | null | |
cpython | cfcd524 | http.cookies | __module__ | >>> C["number"].value | '7' | null |
cpython | cfcd524 | http.cookies | __module__ | >>> C["string"].value | 'seven' | null |
cpython | cfcd524 | http.cookies | __module__ | >>> C.output() | 'Set-Cookie: number=7\r\nSet-Cookie: string=seven'
Finis. | null |
cpython | cfcd524 | http.cookiejar | split_header_words | >>> split_header_words(['foo="bar"; port="80,81"; discard, bar=baz']) | [[('foo', 'bar'), ('port', '80,81'), ('discard', None)], [('bar', 'baz')]] | null |
cpython | cfcd524 | http.cookiejar | split_header_words | >>> split_header_words(['text/html; charset="iso-8859-1"']) | [[('text/html', None), ('charset', 'iso-8859-1')]] | null |
cpython | cfcd524 | http.cookiejar | split_header_words | >>> split_header_words([r'Basic realm="\"foo\bar\""']) | [[('Basic', None), ('realm', '"foobar"')]] | null |
cpython | cfcd524 | http.cookiejar | join_header_words | >>> join_header_words([[("text/plain", None), ("charset", "iso-8859/1")]]) | 'text/plain; charset="iso-8859/1"' | null |
cpython | cfcd524 | http.cookiejar | join_header_words | >>> join_header_words([[("text/plain", None)], [("charset", "iso-8859/1")]]) | 'text/plain, charset="iso-8859/1"' | null |
cpython | cfcd524 | http.cookiejar | reach | >>> reach("www.acme.com") | '.acme.com' | null |
cpython | cfcd524 | http.cookiejar | reach | >>> reach("acme.com") | 'acme.com' | null |
cpython | cfcd524 | http.cookiejar | reach | >>> reach("acme.local") | '.local' | null |
cpython | cfcd524 | typing | _LazyAnnotationLib._should_unflatten_callable_args | >>> import collections.abc | null | |
cpython | cfcd524 | typing | _LazyAnnotationLib._should_unflatten_callable_args | >>> P = ParamSpec('P') | null | |
cpython | cfcd524 | typing | _LazyAnnotationLib._should_unflatten_callable_args | >>> collections.abc.Callable[[int, int], str].__args__ == (int, int, str) | True | null |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.