Dataset Viewer
Auto-converted to Parquet Duplicate
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
subprocess
Handle.check_output
>>> check_output(["ls", "-l", "/dev/null"])
b'crw-rw-rw- 1 root root 1, 3 Oct 18 2007 /dev/null\n' The stdout argument is not allowed as it is used internally. To capture standard error in the result, use stderr=STDOUT.
null
cpython
cfcd524
subprocess
Handle.check_output
>>> check_output(["/bin/sh", "-c", ... "ls -l non_existent_file ; exit 0"], ... stderr=STDOUT)
b'ls: non_existent_file: No such file or directory\n' There is an additional optional argument, "input", allowing you to pass a string to the subprocess's stdin. If you use this argument you may not also use the Popen constructor's "stdin" argument, as it too will be used internally. Example:
null
cpython
cfcd524
subprocess
Handle.check_output
>>> check_output(["sed", "-e", "s/foo/bar/"], ... input=b"when in the course of fooman events\n")
b'when in the course of barman events\n' By default, all communication is in bytes, and therefore any "input" should be bytes, and the return value will be bytes. If in text mode, any "input" should be a string, and the return value will be a string decoded according to locale encoding, or by "encoding" if set. Text mode is triggered by setting any of text, encoding, errors or universal_newlines.
null
cpython
cfcd524
subprocess
CompletedProcess.getstatusoutput
>>> import subprocess
null
cpython
cfcd524
subprocess
CompletedProcess.getstatusoutput
>>> subprocess.getstatusoutput('ls /bin/ls')
(0, '/bin/ls')
null
cpython
cfcd524
subprocess
CompletedProcess.getstatusoutput
>>> subprocess.getstatusoutput('cat /bin/junk')
(1, 'cat: /bin/junk: No such file or directory')
null
cpython
cfcd524
subprocess
CompletedProcess.getstatusoutput
>>> subprocess.getstatusoutput('/bin/junk')
(127, 'sh: /bin/junk: not found')
null
cpython
cfcd524
subprocess
CompletedProcess.getstatusoutput
>>> subprocess.getstatusoutput('/bin/kill $$')
(-15, '')
null
cpython
cfcd524
subprocess
CompletedProcess.getoutput
>>> import subprocess
null
cpython
cfcd524
subprocess
CompletedProcess.getoutput
>>> subprocess.getoutput('ls /bin/ls')
'/bin/ls'
null
cpython
cfcd524
pickle
_Unframer.encode_long
>>> encode_long(0)
b''
null
cpython
cfcd524
pickle
_Unframer.encode_long
>>> encode_long(255)
b'\xff\x00'
null
cpython
cfcd524
pickle
_Unframer.encode_long
>>> encode_long(32767)
b'\xff\x7f'
null
cpython
cfcd524
pickle
_Unframer.encode_long
>>> encode_long(-256)
b'\x00\xff'
null
cpython
cfcd524
pickle
_Unframer.encode_long
>>> encode_long(-32768)
b'\x00\x80'
null
cpython
cfcd524
pickle
_Unframer.encode_long
>>> encode_long(-128)
b'\x80'
null
cpython
cfcd524
pickle
_Unframer.encode_long
>>> encode_long(127)
b'\x7f'
null
cpython
cfcd524
pickle
_Unframer.encode_long
>>>
null
cpython
cfcd524
pickle
_Unframer.decode_long
>>> decode_long(b'')
0
null
cpython
cfcd524
pickle
_Unframer.decode_long
>>> decode_long(b"\xff\x00")
255
null
cpython
cfcd524
pickle
_Unframer.decode_long
>>> decode_long(b"\xff\x7f")
32767
null
cpython
cfcd524
pickle
_Unframer.decode_long
>>> decode_long(b"\x00\xff")
-256
null
cpython
cfcd524
pickle
_Unframer.decode_long
>>> decode_long(b"\x00\x80")
-32768
null
cpython
cfcd524
pickle
_Unframer.decode_long
>>> decode_long(b"\x80")
-128
null
cpython
cfcd524
pickle
_Unframer.decode_long
>>> decode_long(b"\x7f")
127
null
cpython
cfcd524
decimal
__module__
>>> from decimal import *
null
cpython
cfcd524
decimal
__module__
>>> setcontext(ExtendedContext)
null
cpython
cfcd524
decimal
__module__
>>> Decimal(0)
Decimal('0')
null
cpython
cfcd524
decimal
__module__
>>> Decimal('1')
Decimal('1')
null
cpython
cfcd524
decimal
__module__
>>> Decimal('-.0123')
Decimal('-0.0123')
null
cpython
cfcd524
decimal
__module__
>>> Decimal(123456)
Decimal('123456')
null
cpython
cfcd524
decimal
__module__
>>> Decimal('123.45e12345678')
Decimal('1.2345E+12345680')
null
cpython
cfcd524
decimal
__module__
>>> Decimal('1.33') + Decimal('1.27')
Decimal('2.60')
null
cpython
cfcd524
decimal
__module__
>>> Decimal('12.34') + Decimal('3.87') - Decimal('18.41')
Decimal('-2.20')
null
cpython
cfcd524
decimal
__module__
>>> dig = Decimal(1)
null
cpython
cfcd524
decimal
__module__
>>> print(dig / Decimal(3))
0.333333333
null
cpython
cfcd524
decimal
__module__
>>> getcontext().prec = 18
null
cpython
cfcd524
decimal
__module__
>>> print(dig / Decimal(3))
0.333333333333333333
null
cpython
cfcd524
decimal
__module__
>>> print(dig.sqrt())
1
null
cpython
cfcd524
decimal
__module__
>>> print(Decimal(3).sqrt())
1.73205080756887729
null
cpython
cfcd524
decimal
__module__
>>> print(Decimal(3) ** 123)
4.85192780976896427E+58
null
cpython
cfcd524
decimal
__module__
>>> inf = Decimal(1) / Decimal(0)
null
cpython
cfcd524
decimal
__module__
>>> print(inf)
Infinity
null
cpython
cfcd524
decimal
__module__
>>> neginf = Decimal(-1) / Decimal(0)
null
cpython
cfcd524
decimal
__module__
>>> print(neginf)
-Infinity
null
cpython
cfcd524
decimal
__module__
>>> print(neginf + inf)
NaN
null
cpython
cfcd524
decimal
__module__
>>> print(neginf * inf)
-Infinity
null
cpython
cfcd524
decimal
__module__
>>> print(dig / 0)
Infinity
null
cpython
cfcd524
decimal
__module__
>>> getcontext().traps[DivisionByZero] = 1
null
cpython
cfcd524
decimal
__module__
>>> print(dig / 0)
Traceback (most recent call last): ... ... ... decimal.DivisionByZero: x / 0
null
cpython
cfcd524
decimal
__module__
>>> c = Context()
null
cpython
cfcd524
decimal
__module__
>>> c.traps[InvalidOperation] = 0
null
cpython
cfcd524
decimal
__module__
>>> print(c.flags[InvalidOperation])
0
null
cpython
cfcd524
decimal
__module__
>>> c.divide(Decimal(0), Decimal(0))
Decimal('NaN')
null
cpython
cfcd524
decimal
__module__
>>> c.traps[InvalidOperation] = 1
null
cpython
cfcd524
decimal
__module__
>>> print(c.flags[InvalidOperation])
1
null
cpython
cfcd524
decimal
__module__
>>> c.flags[InvalidOperation] = 0
null
cpython
cfcd524
decimal
__module__
>>> print(c.flags[InvalidOperation])
0
null
cpython
cfcd524
decimal
__module__
>>> print(c.divide(Decimal(0), Decimal(0)))
Traceback (most recent call last): ... ... ... decimal.InvalidOperation: 0 / 0
null
cpython
cfcd524
decimal
__module__
>>> print(c.flags[InvalidOperation])
1
null
cpython
cfcd524
decimal
__module__
>>> c.flags[InvalidOperation] = 0
null
cpython
cfcd524
decimal
__module__
>>> c.traps[InvalidOperation] = 0
null
cpython
cfcd524
decimal
__module__
>>> print(c.divide(Decimal(0), Decimal(0)))
NaN
null
cpython
cfcd524
decimal
__module__
>>> print(c.flags[InvalidOperation])
1
null
cpython
cfcd524
decimal
__module__
>>>
null
cpython
cfcd524
pickletools
ArgumentDescriptor.read_uint1
>>> import io
null
cpython
cfcd524
pickletools
ArgumentDescriptor.read_uint1
>>> read_uint1(io.BytesIO(b'\xff'))
255
null
cpython
cfcd524
pickletools
ArgumentDescriptor.read_uint2
>>> import io
null
cpython
cfcd524
pickletools
ArgumentDescriptor.read_uint2
>>> read_uint2(io.BytesIO(b'\xff\x00'))
255
null
cpython
cfcd524
pickletools
ArgumentDescriptor.read_uint2
>>> read_uint2(io.BytesIO(b'\xff\xff'))
65535
null
cpython
cfcd524
pickletools
ArgumentDescriptor.read_int4
>>> import io
null
cpython
cfcd524
pickletools
ArgumentDescriptor.read_int4
>>> read_int4(io.BytesIO(b'\xff\x00\x00\x00'))
255
null
cpython
cfcd524
pickletools
ArgumentDescriptor.read_int4
>>> read_int4(io.BytesIO(b'\x00\x00\x00\x80')) == -(2**31)
True
null
cpython
cfcd524
pickletools
ArgumentDescriptor.read_uint4
>>> import io
null
cpython
cfcd524
pickletools
ArgumentDescriptor.read_uint4
>>> read_uint4(io.BytesIO(b'\xff\x00\x00\x00'))
255
null
cpython
cfcd524
pickletools
ArgumentDescriptor.read_uint4
>>> read_uint4(io.BytesIO(b'\x00\x00\x00\x80')) == 2**31
True
null
cpython
cfcd524
pickletools
ArgumentDescriptor.read_uint8
>>> import io
null
cpython
cfcd524
pickletools
ArgumentDescriptor.read_uint8
>>> read_uint8(io.BytesIO(b'\xff\x00\x00\x00\x00\x00\x00\x00'))
255
null
cpython
cfcd524
pickletools
ArgumentDescriptor.read_uint8
>>> read_uint8(io.BytesIO(b'\xff' * 8)) == 2**64-1
True
null
cpython
cfcd524
pickletools
ArgumentDescriptor.read_stringnl
>>> import io
null
cpython
cfcd524
pickletools
ArgumentDescriptor.read_stringnl
>>> read_stringnl(io.BytesIO(b"'abcd'\nefg\n"))
'abcd'
null
cpython
cfcd524
pickletools
ArgumentDescriptor.read_stringnl
>>> read_stringnl(io.BytesIO(b"\n"))
Traceback (most recent call last): ... ValueError: no string quotes around b''
null
cpython
cfcd524
pickletools
ArgumentDescriptor.read_stringnl
>>> read_stringnl(io.BytesIO(b"\n"), stripquotes=False)
''
null
cpython
cfcd524
pickletools
ArgumentDescriptor.read_stringnl
>>> read_stringnl(io.BytesIO(b"''\n"))
''
null
cpython
cfcd524
pickletools
ArgumentDescriptor.read_stringnl
>>> read_stringnl(io.BytesIO(b'"abcd"'))
Traceback (most recent call last): ... ValueError: no newline found when trying to read stringnl Embedded escapes are undone in the result.
null
cpython
cfcd524
pickletools
ArgumentDescriptor.read_stringnl
>>> read_stringnl(io.BytesIO(br"'a\n\\b\x00c\td'" + b"\n'e'"))
'a\n\\b\x00c\td'
null
cpython
cfcd524
pickletools
ArgumentDescriptor.read_stringnl_noescape_pair
>>> import io
null
cpython
cfcd524
pickletools
ArgumentDescriptor.read_stringnl_noescape_pair
>>> read_stringnl_noescape_pair(io.BytesIO(b"Queue\nEmpty\njunk"))
'Queue Empty'
null
cpython
cfcd524
pickletools
ArgumentDescriptor.read_string1
>>> import io
null
cpython
cfcd524
pickletools
ArgumentDescriptor.read_string1
>>> read_string1(io.BytesIO(b"\x00"))
''
null
cpython
cfcd524
pickletools
ArgumentDescriptor.read_string1
>>> read_string1(io.BytesIO(b"\x03abcdef"))
'abc'
null
cpython
cfcd524
pickletools
ArgumentDescriptor.read_string4
>>> import io
null
cpython
cfcd524
pickletools
ArgumentDescriptor.read_string4
>>> read_string4(io.BytesIO(b"\x00\x00\x00\x00abc"))
''
null
cpython
cfcd524
pickletools
ArgumentDescriptor.read_string4
>>> read_string4(io.BytesIO(b"\x03\x00\x00\x00abcdef"))
'abc'
null
cpython
cfcd524
pickletools
ArgumentDescriptor.read_string4
>>> read_string4(io.BytesIO(b"\x00\x00\x00\x03abcdef"))
Traceback (most recent call last): ... ValueError: expected 50331648 bytes in a string4, but only 6 remain
null
cpython
cfcd524
pickletools
ArgumentDescriptor.read_bytes1
>>> import io
null
cpython
cfcd524
pickletools
ArgumentDescriptor.read_bytes1
>>> read_bytes1(io.BytesIO(b"\x00"))
b''
null
cpython
cfcd524
pickletools
ArgumentDescriptor.read_bytes1
>>> read_bytes1(io.BytesIO(b"\x03abcdef"))
b'abc'
null
cpython
cfcd524
pickletools
ArgumentDescriptor.read_bytes4
>>> import io
null
cpython
cfcd524
pickletools
ArgumentDescriptor.read_bytes4
>>> read_bytes4(io.BytesIO(b"\x00\x00\x00\x00abc"))
b''
null
End of preview. Expand in Data Studio

Python Doctest Corpus

A curated corpus of Python doctest examples designed for training Python-to-Rust transpilers and testing code translation systems.

Dataset Description

This dataset contains Python function signatures, doctest inputs, and expected outputs that serve as high-quality training data for:

  • Transpilation training: Teaching models to translate Python patterns to Rust
  • Test validation: Verifying that transpiled code produces correct outputs
  • Code understanding: Benchmarking code comprehension systems

Schema

Column Type Description
source string Source project identifier
version string Git commit SHA or version
module string Module path (e.g., example_math.math_tool)
function string Function name being tested
input string Python doctest input (e.g., >>> square(5))
expected string Expected output value
signature string Full Python function signature with type hints

Quality Score

Quality score validated using alimentar quality score --profile doctest-corpus:

  • Grade: B (90.3%)
  • Critical Checks: All passing
  • High Priority Checks: All passing

Example

def square(x: int) -> int:
    """
    >>> square(5)
    25
    >>> square(0)
    0
    """
    return x * x

Becomes:

{
  "source": "reprorusted-python-cli",
  "function": "square",
  "input": ">>> square(5)",
  "expected": "25",
  "signature": "def square(x: int) -> int"
}

Usage

from datasets import load_dataset

dataset = load_dataset("paiml/python-doctest-corpus")

for example in dataset["train"]:
    print(f"{example['function']}: {example['input']} -> {example['expected']}")

License

Apache 2.0

Citation

@dataset{python_doctest_corpus,
  author = {PAIML},
  title = {Python Doctest Corpus},
  year = {2025},
  publisher = {HuggingFace},
  url = {https://huggingface.co/datasets/paiml/python-doctest-corpus}
}
Downloads last month
14