source
stringclasses
2 values
version
stringclasses
2 values
module
stringclasses
53 values
function
stringclasses
318 values
input
stringlengths
3
496
expected
stringlengths
0
876
signature
stringclasses
41 values
cpython
3.10
http.cookies
__module__
>>> C["rocky"] = "road"
null
cpython
3.10
http.cookies
__module__
>>> C["rocky"]["path"] = "/cookie"
null
cpython
3.10
http.cookies
__module__
>>> print(C.output(header="Cookie:"))
null
cpython
3.10
http.cookies
__module__
>>> print(C.output(attrs=[], header="Cookie:"))
Cookie: rocky=road
null
cpython
3.10
http.cookies
__module__
>>> C = cookies.SimpleCookie()
null
cpython
3.10
http.cookies
__module__
>>> C.load("chips=ahoy; vienna=finger")
null
cpython
3.10
http.cookies
__module__
>>> C.output()
'Set-Cookie: chips=ahoy\r\nSet-Cookie: vienna=finger'
null
cpython
3.10
http.cookies
__module__
>>> C = cookies.SimpleCookie()
null
cpython
3.10
http.cookies
__module__
>>> C.load('keebler="E=everybody; L=\\"Loves\\"; fudge=\\012;";')
null
cpython
3.10
http.cookies
__module__
>>> print(C)
null
cpython
3.10
http.cookies
__module__
>>> C = cookies.SimpleCookie()
null
cpython
3.10
http.cookies
__module__
>>> C["oreo"] = "doublestuff"
null
cpython
3.10
http.cookies
__module__
>>> C["oreo"]["path"] = "/"
null
cpython
3.10
http.cookies
__module__
>>> print(C)
null
cpython
3.10
http.cookies
__module__
>>> C = cookies.SimpleCookie()
null
cpython
3.10
http.cookies
__module__
>>> C["twix"] = "none for you"
null
cpython
3.10
http.cookies
__module__
>>> C["twix"].value
'none for you'
null
cpython
3.10
http.cookies
__module__
>>> C = cookies.SimpleCookie()
null
cpython
3.10
http.cookies
__module__
>>> C["number"] = 7
null
cpython
3.10
http.cookies
__module__
>>> C["string"] = "seven"
null
cpython
3.10
http.cookies
__module__
>>> C["number"].value
'7'
null
cpython
3.10
http.cookies
__module__
>>> C["string"].value
'seven'
null
cpython
3.10
http.cookies
__module__
>>> C.output()
'Set-Cookie: number=7\r\nSet-Cookie: string=seven' Finis.
null
cpython
3.10
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
3.10
http.cookiejar
split_header_words
>>> split_header_words(['text/html; charset="iso-8859-1"'])
[[('text/html', None), ('charset', 'iso-8859-1')]]
null
cpython
3.10
http.cookiejar
split_header_words
>>> split_header_words([r'Basic realm="\"foo\bar\""'])
[[('Basic', None), ('realm', '"foobar"')]]
null
cpython
3.10
http.cookiejar
join_header_words
>>> join_header_words([[("text/plain", None), ("charset", "iso-8859-1")]])
'text/plain; charset="iso-8859-1"'
null
cpython
3.10
http.cookiejar
join_header_words
>>> join_header_words([[("text/plain", None)], [("charset", "iso-8859-1")]])
'text/plain, charset="iso-8859-1"'
null
cpython
3.10
http.cookiejar
reach
>>> reach("www.acme.com")
'.acme.com'
null
cpython
3.10
http.cookiejar
reach
>>> reach("acme.com")
'acme.com'
null
cpython
3.10
http.cookiejar
reach
>>> reach("acme.local")
'.local'
null
cpython
3.10
fractions
Fraction.__new__
>>> Fraction(10, -8)
Fraction(-5, 4)
null
cpython
3.10
fractions
Fraction.__new__
>>> Fraction(Fraction(1, 7), 5)
Fraction(1, 35)
null
cpython
3.10
fractions
Fraction.__new__
>>> Fraction(Fraction(1, 7), Fraction(2, 3))
Fraction(3, 14)
null
cpython
3.10
fractions
Fraction.__new__
>>> Fraction('314')
Fraction(314, 1)
null
cpython
3.10
fractions
Fraction.__new__
>>> Fraction('-35/4')
Fraction(-35, 4)
null
cpython
3.10
fractions
Fraction.__new__
>>> Fraction('3.1415') # conversion from numeric string
Fraction(6283, 2000)
null
cpython
3.10
fractions
Fraction.__new__
>>> Fraction('-47e-2') # string may include a decimal exponent
Fraction(-47, 100)
null
cpython
3.10
fractions
Fraction.__new__
>>> Fraction(1.47) # direct construction from float (exact conversion)
Fraction(6620291452234629, 4503599627370496)
null
cpython
3.10
fractions
Fraction.__new__
>>> Fraction(2.25)
Fraction(9, 4)
null
cpython
3.10
fractions
Fraction.__new__
>>> Fraction(Decimal('1.47'))
Fraction(147, 100)
null
cpython
3.10
fractions
Fraction.limit_denominator
>>> Fraction('3.141592653589793').limit_denominator(10)
Fraction(22, 7)
null
cpython
3.10
fractions
Fraction.limit_denominator
>>> Fraction('3.141592653589793').limit_denominator(100)
Fraction(311, 99)
null
cpython
3.10
fractions
Fraction.limit_denominator
>>> Fraction(4321, 8765).limit_denominator(10000)
Fraction(4321, 8765)
null
cpython
3.10
distutils.versionpredicate
VersionPredicate
>>> v = VersionPredicate('pyepat.abc (>1.0, <3333.3a1, !=1555.1b3)')
null
cpython
3.10
distutils.versionpredicate
VersionPredicate
>>> v.name
'pyepat.abc'
null
cpython
3.10
distutils.versionpredicate
VersionPredicate
>>> print(v)
pyepat.abc (> 1.0, < 3333.3a1, != 1555.1b3)
null
cpython
3.10
distutils.versionpredicate
VersionPredicate
>>> v.satisfied_by('1.1')
True
null
cpython
3.10
distutils.versionpredicate
VersionPredicate
>>> v.satisfied_by('1.4')
True
null
cpython
3.10
distutils.versionpredicate
VersionPredicate
>>> v.satisfied_by('1.0')
False
null
cpython
3.10
distutils.versionpredicate
VersionPredicate
>>> v.satisfied_by('4444.4')
False
null
cpython
3.10
distutils.versionpredicate
VersionPredicate
>>> v.satisfied_by('1555.1b3')
False `VersionPredicate` is flexible in accepting extra whitespace::
null
cpython
3.10
distutils.versionpredicate
VersionPredicate
>>> v = VersionPredicate(' pat( == 0.1 ) ')
null
cpython
3.10
distutils.versionpredicate
VersionPredicate
>>> v.name
'pat'
null
cpython
3.10
distutils.versionpredicate
VersionPredicate
>>> v.satisfied_by('0.1')
True
null
cpython
3.10
distutils.versionpredicate
VersionPredicate
>>> v.satisfied_by('0.2')
False
null
cpython
3.10
distutils.versionpredicate
VersionPredicate
>>> v = VersionPredicate('p1.p2.p3.p4(>=1.0, <=1.3a1, !=1.2zb3)')
Traceback (most recent call last): ... ValueError: invalid version number '1.2zb3'
null
cpython
3.10
distutils.versionpredicate
VersionPredicate
>>> v = VersionPredicate('foo-bar')
Traceback (most recent call last): ... ValueError: expected parenthesized list: '-bar'
null
cpython
3.10
distutils.versionpredicate
VersionPredicate
>>> v = VersionPredicate('foo bar (12.21)')
Traceback (most recent call last): ... ValueError: expected parenthesized list: 'bar (12.21)'
null
cpython
3.10
distutils.versionpredicate
VersionPredicate.split_provision
>>> split_provision('mypkg')
('mypkg', None)
null
cpython
3.10
distutils.versionpredicate
VersionPredicate.split_provision
>>> split_provision(' mypkg( 1.2 ) ')
('mypkg', StrictVersion ('1.2'))
null
cpython
3.10
distutils.command.sdist
sdist._cs_path_exists
>>> sdist._cs_path_exists(__file__)
True
null
cpython
3.10
distutils.command.sdist
sdist._cs_path_exists
>>> sdist._cs_path_exists(__file__.upper())
False
null
cpython
3.10
secrets
token_bytes
>>> token_bytes(16) #doctest:+SKIP
b'\\xebr\\x17D*t\\xae\\xd4\\xe3S\\xb6\\xe2\\xebP1\\x8b'
null
cpython
3.10
secrets
token_hex
>>> token_hex(16) #doctest:+SKIP
'f9bf78b9a18ce6d46a0cd2b0b86df9da'
null
cpython
3.10
secrets
token_urlsafe
>>> token_urlsafe(16) #doctest:+SKIP
'Drmhze6EPcv0fN_81Bj-nA'
null
cpython
3.10
smtplib
SMTP.sendmail
>>> import smtplib
null
cpython
3.10
smtplib
SMTP.sendmail
>>> s=smtplib.SMTP("localhost")
null
cpython
3.10
smtplib
SMTP.sendmail
>>> tolist=["one@one.org","two@two.org","three@three.org","four@four.org"]
null
cpython
3.10
smtplib
SMTP.sendmail
>>> msg = '''\\ ... From: Me@my.org ... Subject: testin'... ... ... This is a test '''
null
cpython
3.10
smtplib
SMTP.sendmail
>>> s.sendmail("me@my.org",tolist,msg)
{ "three@three.org" : ( 550 ,"User unknown" ) }
null
cpython
3.10
smtplib
SMTP.sendmail
>>> s.quit()
null
cpython
3.10
hashlib
__module__
>>> import hashlib
null
cpython
3.10
hashlib
__module__
>>> m = hashlib.md5()
null
cpython
3.10
hashlib
__module__
>>> m.update(b"Nobody inspects")
null
cpython
3.10
hashlib
__module__
>>> m.update(b" the spammish repetition")
null
cpython
3.10
hashlib
__module__
>>> m.digest()
b'\\xbbd\\x9c\\x83\\xdd\\x1e\\xa5\\xc9\\xd9\\xde\\xc9\\xa1\\x8d\\xf0\\xff\\xe9' More condensed:
null
cpython
3.10
hashlib
__module__
>>> hashlib.sha224(b"Nobody inspects the spammish repetition").hexdigest()
'a4337bc45a8fc544c03f52dc550cd6e1e87021bc896588bd79e901e2'
null
cpython
3.10
ftplib
__module__
>>> from ftplib import FTP
null
cpython
3.10
ftplib
__module__
>>> ftp = FTP('ftp.python.org') # connect to host, default port
null
cpython
3.10
ftplib
__module__
>>> ftp.login() # default, i.e.: user anonymous, passwd anonymous@
'230 Guest login ok, access restrictions apply.'
null
cpython
3.10
ftplib
__module__
>>> ftp.retrlines('LIST') # list directory contents
total 9 drwxr-xr-x 8 root wheel 1024 Jan 3 1994 . drwxr-xr-x 8 root wheel 1024 Jan 3 1994 .. drwxr-xr-x 2 root wheel 1024 Jan 3 1994 bin drwxr-xr-x 2 root wheel 1024 Jan 3 1994 etc d-wxrwxr-x 2 ftp wheel 1024 Sep 5 13:43 incoming drwxr-xr-x 2 root wheel 1024 Nov 17 1993 lib drwxr-xr-x 6 1094 wheel 1024 Sep 13 19:07 pub drwxr-xr-x 3 root wheel 1024 Jan 3 1994 usr -rw-r--r-- 1 root root 312 Aug 1 1994 welcome.msg '226 Transfer complete.'
null
cpython
3.10
ftplib
__module__
>>> ftp.quit()
'221 Goodbye.'
null
cpython
3.10
ftplib
__module__
>>>
null
cpython
3.10
statistics
__module__
>>> mean([-1.0, 2.5, 3.25, 5.75])
2.625
null
cpython
3.10
statistics
__module__
>>> median([2, 3, 4, 5])
3.5
null
cpython
3.10
statistics
__module__
>>> median_grouped([2, 2, 3, 3, 3, 4]) #doctest: +ELLIPSIS
2.8333333333...
null
cpython
3.10
statistics
__module__
>>> stdev([2.5, 3.25, 5.5, 11.25, 11.75]) #doctest: +ELLIPSIS
4.38961843444...
null
cpython
3.10
statistics
__module__
>>> data = [1, 2, 2, 4, 4, 4, 5, 6]
null
cpython
3.10
statistics
__module__
>>> mu = mean(data)
null
cpython
3.10
statistics
__module__
>>> pvariance(data, mu)
2.5
null
cpython
3.10
statistics
__module__
>>> x = [1, 2, 3, 4, 5, 6, 7, 8, 9]
null
cpython
3.10
statistics
__module__
>>> y = [1, 2, 3, 1, 2, 3, 1, 2, 3]
null
cpython
3.10
statistics
__module__
>>> covariance(x, y)
0.75
null
cpython
3.10
statistics
__module__
>>> correlation(x, y) #doctest: +ELLIPSIS
0.31622776601...
null
cpython
3.10
statistics
__module__
>>> linear_regression(x, y) #doctest:
LinearRegression(slope=0.1, intercept=1.5) Exceptions ----------
null
cpython
3.10
statistics
StatisticsError._sum
>>> _sum([3, 2.25, 4.5, -0.5, 0.25])
(<class 'float'>, Fraction(19, 2), 5)
null
cpython
3.10
statistics
StatisticsError._sum
>>> _sum([1e50, 1, -1e50] * 1000)
(<class 'float'>, Fraction(1000, 1), 3000)
null
cpython
3.10
statistics
StatisticsError._sum
>>> from fractions import Fraction as F
null
cpython
3.10
statistics
StatisticsError._sum
>>> _sum([F(2, 3), F(7, 5), F(1, 4), F(5, 6)])
(<class 'fractions.Fraction'>, Fraction(63, 20), 4)
null