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
turtle
RawTurtle.begin_fill
>>> turtle.color("black", "red")
null
cpython
3.10
turtle
RawTurtle.begin_fill
>>> turtle.begin_fill()
null
cpython
3.10
turtle
RawTurtle.begin_fill
>>> turtle.circle(60)
null
cpython
3.10
turtle
RawTurtle.begin_fill
>>> turtle.end_fill()
null
cpython
3.10
turtle
RawTurtle.end_fill
>>> turtle.color("black", "red")
null
cpython
3.10
turtle
RawTurtle.end_fill
>>> turtle.begin_fill()
null
cpython
3.10
turtle
RawTurtle.end_fill
>>> turtle.circle(60)
null
cpython
3.10
turtle
RawTurtle.end_fill
>>> turtle.end_fill()
null
cpython
3.10
turtle
RawTurtle.dot
>>> turtle.dot()
null
cpython
3.10
turtle
RawTurtle.dot
>>> turtle.fd(50); turtle.dot(20, "blue"); turtle.fd(50)
null
cpython
3.10
turtle
RawTurtle.write
>>> turtle.write('Home = ', True, align="center")
null
cpython
3.10
turtle
RawTurtle.write
>>> turtle.write((0,0), True)
null
cpython
3.10
turtle
RawTurtle.begin_poly
>>> turtle.begin_poly()
null
cpython
3.10
turtle
RawTurtle.end_poly
>>> turtle.end_poly()
null
cpython
3.10
turtle
RawTurtle.get_poly
>>> p = turtle.get_poly()
null
cpython
3.10
turtle
RawTurtle.get_poly
>>> turtle.register_shape("myFavouriteShape", p)
null
cpython
3.10
turtle
RawTurtle.getscreen
>>> ts = turtle.getscreen()
null
cpython
3.10
turtle
RawTurtle.getscreen
>>> ts
<turtle.TurtleScreen object at 0x0106B770>
null
cpython
3.10
turtle
RawTurtle.getscreen
>>> ts.bgcolor("pink")
null
cpython
3.10
turtle
RawTurtle.getturtle
>>> pet = getturtle()
null
cpython
3.10
turtle
RawTurtle.getturtle
>>> pet.fd(50)
null
cpython
3.10
turtle
RawTurtle.getturtle
>>> pet
<turtle.Turtle object at 0x0187D810>
null
cpython
3.10
turtle
RawTurtle.getturtle
>>> turtles()
[<turtle.Turtle object at 0x0187D810>]
null
cpython
3.10
turtle
RawTurtle.onclick
>>> def turn(x, y): ... left(360) ...
null
cpython
3.10
turtle
RawTurtle.onclick
>>> onclick(turn) # Now clicking into the turtle will turn it.
null
cpython
3.10
turtle
RawTurtle.onclick
>>> onclick(None) # event-binding will be removed
null
cpython
3.10
turtle
RawTurtle.onrelease
>>> class MyTurtle(Turtle): ... def glow(self,x,y): ... self.fillcolor("red") ... def unglow(self,x,y): ... self.fillcolor("") ...
null
cpython
3.10
turtle
RawTurtle.onrelease
>>> joe = MyTurtle()
null
cpython
3.10
turtle
RawTurtle.onrelease
>>> joe.onclick(joe.glow)
null
cpython
3.10
turtle
RawTurtle.onrelease
>>> joe.onrelease(joe.unglow)
null
cpython
3.10
turtle
RawTurtle.ondrag
>>> turtle.ondrag(turtle.goto)
null
cpython
3.10
turtle
RawTurtle.undo
>>> for i in range(4): ... turtle.fd(50); turtle.lt(80) ...
null
cpython
3.10
turtle
RawTurtle.undo
>>> for i in range(8): ... turtle.undo() ...
null
cpython
3.10
turtle
_Screen.setup
>>> screen.setup (width=200, height=200, startx=0, starty=0)
sets window to 200x200 pixels, in upper left of screen
null
cpython
3.10
turtle
_Screen.setup
>>> screen.setup(width=.75, height=0.5, startx=None, starty=None)
sets window to 75% of screen by 50% of screen and centers
null
cpython
3.10
turtle
_Screen.title
>>> screen.title("Welcome to the turtle-zoo!")
null
cpython
3.10
turtle
_Screen.bye
>>> screen.bye()
null
cpython
3.10
turtle
_Screen.exitonclick
>>> screen.exitonclick()
null
cpython
3.10
zipfile
PyZipFile._parents
>>> list(_parents('b/d'))
['b']
null
cpython
3.10
zipfile
PyZipFile._parents
>>> list(_parents('/b/d/'))
['/b']
null
cpython
3.10
zipfile
PyZipFile._parents
>>> list(_parents('b/d/f/'))
['b/d', 'b']
null
cpython
3.10
zipfile
PyZipFile._parents
>>> list(_parents('b'))
[]
null
cpython
3.10
zipfile
PyZipFile._parents
>>> list(_parents(''))
[]
null
cpython
3.10
zipfile
PyZipFile._ancestry
>>> list(_ancestry('b/d'))
['b/d', 'b']
null
cpython
3.10
zipfile
PyZipFile._ancestry
>>> list(_ancestry('/b/d/'))
['/b/d', '/b']
null
cpython
3.10
zipfile
PyZipFile._ancestry
>>> list(_ancestry('b/d/f/'))
['b/d/f', 'b/d', 'b']
null
cpython
3.10
zipfile
PyZipFile._ancestry
>>> list(_ancestry('b'))
['b']
null
cpython
3.10
zipfile
PyZipFile._ancestry
>>> list(_ancestry(''))
[]
null
cpython
3.10
zipfile
PyZipFile._ancestry
>>> list(_ancestry('//b//d///f//'))
['//b//d///f', '//b//d', '//b']
null
cpython
3.10
zipfile
Path
>>> data = io.BytesIO()
null
cpython
3.10
zipfile
Path
>>> zf = ZipFile(data, 'w')
null
cpython
3.10
zipfile
Path
>>> zf.writestr('a.txt', 'content of a')
null
cpython
3.10
zipfile
Path
>>> zf.writestr('b/c.txt', 'content of c')
null
cpython
3.10
zipfile
Path
>>> zf.writestr('b/d/e.txt', 'content of e')
null
cpython
3.10
zipfile
Path
>>> zf.filename = 'mem/abcde.zip'
null
cpython
3.10
zipfile
Path
>>> root = Path(zf)
null
cpython
3.10
zipfile
Path
>>> a, b = root.iterdir()
null
cpython
3.10
zipfile
Path
>>> a
Path('mem/abcde.zip', 'a.txt')
null
cpython
3.10
zipfile
Path
>>> b
Path('mem/abcde.zip', 'b/') name property:
null
cpython
3.10
zipfile
Path
>>> b.name
'b' join with divide operator:
null
cpython
3.10
zipfile
Path
>>> c = b / 'c.txt'
null
cpython
3.10
zipfile
Path
>>> c
Path('mem/abcde.zip', 'b/c.txt')
null
cpython
3.10
zipfile
Path
>>> c.name
'c.txt' Read text:
null
cpython
3.10
zipfile
Path
>>> c.read_text()
'content of c' existence:
null
cpython
3.10
zipfile
Path
>>> c.exists()
True
null
cpython
3.10
zipfile
Path
>>> (b / 'missing.txt').exists()
False
null
cpython
3.10
zipfile
Path
>>> import os
null
cpython
3.10
zipfile
Path
>>> str(c).replace(os.sep, posixpath.sep)
'mem/abcde.zip/b/c.txt'
null
cpython
3.10
zipfile
Path
>>> root.name
'abcde.zip'
null
cpython
3.10
zipfile
Path
>>> str(root.filename).replace(os.sep, posixpath.sep)
'mem/abcde.zip'
null
cpython
3.10
zipfile
Path
>>> str(root.parent)
'mem'
null
cpython
3.10
uuid
__module__
>>> import uuid
# make a UUID based on the host ID and current time
null
cpython
3.10
uuid
__module__
>>> uuid.uuid1() # doctest: +SKIP
UUID('a8098c1a-f86e-11da-bd1a-00112444be1e') # make a UUID using an MD5 hash of a namespace UUID and a name
null
cpython
3.10
uuid
__module__
>>> uuid.uuid3(uuid.NAMESPACE_DNS, 'python.org')
UUID('6fa459ea-ee8a-3ca4-894e-db77e160355e') # make a random UUID
null
cpython
3.10
uuid
__module__
>>> uuid.uuid4() # doctest: +SKIP
UUID('16fd2706-8baf-433b-82eb-8c7fada847da') # make a UUID using a SHA-1 hash of a namespace UUID and a name
null
cpython
3.10
uuid
__module__
>>> uuid.uuid5(uuid.NAMESPACE_DNS, 'python.org')
UUID('886313e1-3b8a-5372-9b90-0c9aee199e5d') # make a UUID from a string of hex digits (braces and hyphens ignored)
null
cpython
3.10
uuid
__module__
>>> x = uuid.UUID('{00010203-0405-0607-0809-0a0b0c0d0e0f}')
# convert a UUID to a string of hex digits in standard form
null
cpython
3.10
uuid
__module__
>>> str(x)
'00010203-0405-0607-0809-0a0b0c0d0e0f' # get the raw 16 bytes of the UUID
null
cpython
3.10
uuid
__module__
>>> x.bytes
b'\x00\x01\x02\x03\x04\x05\x06\x07\x08\t\n\x0b\x0c\r\x0e\x0f' # make a UUID from a 16-byte string
null
cpython
3.10
uuid
__module__
>>> uuid.UUID(bytes=x.bytes)
UUID('00010203-0405-0607-0809-0a0b0c0d0e0f')
null
cpython
3.10
collections
OrderedDict.namedtuple
>>> Point = namedtuple('Point', ['x', 'y'])
null
cpython
3.10
collections
OrderedDict.namedtuple
>>> Point.__doc__ # docstring for the new class
'Point(x, y)'
null
cpython
3.10
collections
OrderedDict.namedtuple
>>> p = Point(11, y=22) # instantiate with positional args or keywords
null
cpython
3.10
collections
OrderedDict.namedtuple
>>> p[0] + p[1] # indexable like a plain tuple
33
null
cpython
3.10
collections
OrderedDict.namedtuple
>>> x, y = p # unpack like a regular tuple
null
cpython
3.10
collections
OrderedDict.namedtuple
>>> x, y
(11, 22)
null
cpython
3.10
collections
OrderedDict.namedtuple
>>> p.x + p.y # fields also accessible by name
33
null
cpython
3.10
collections
OrderedDict.namedtuple
>>> d = p._asdict() # convert to a dictionary
null
cpython
3.10
collections
OrderedDict.namedtuple
>>> d['x']
11
null
cpython
3.10
collections
OrderedDict.namedtuple
>>> Point(**d) # convert from a dictionary
Point(x=11, y=22)
null
cpython
3.10
collections
OrderedDict.namedtuple
>>> p._replace(x=100) # _replace() is like str.replace() but targets named fields
Point(x=100, y=22)
null
cpython
3.10
tempfile
__module__
>>> tempfile.mkstemp()
(4, '/tmp/tmptpu9nin8')
null
cpython
3.10
tempfile
__module__
>>> tempfile.mkdtemp(suffix=b'')
b'/tmp/tmppbi8f0hy'
null
cpython
3.10
importlib.metadata._text
FoldedCase
>>> s = FoldedCase('hello world')
null
cpython
3.10
importlib.metadata._text
FoldedCase
>>> s == 'Hello World'
True
null
cpython
3.10
importlib.metadata._text
FoldedCase
>>> 'Hello World' == s
True
null
cpython
3.10
importlib.metadata._text
FoldedCase
>>> s != 'Hello World'
False
null
cpython
3.10
importlib.metadata._text
FoldedCase
>>> s.index('O')
4
null
cpython
3.10
importlib.metadata._text
FoldedCase
>>> s.split('O')
['hell', ' w', 'rld']
null
cpython
3.10
importlib.metadata._text
FoldedCase
>>> sorted(map(FoldedCase, ['GAMMA', 'alpha', 'Beta']))
['alpha', 'Beta', 'GAMMA']
null