doc_content stringlengths 1 386k | doc_id stringlengths 5 188 |
|---|---|
dis.cmp_op
Sequence of all compare operation names. | python.library.dis#dis.cmp_op |
dis.code_info(x)
Return a formatted multi-line string with detailed code object information for the supplied function, generator, asynchronous generator, coroutine, method, source code string or code object. Note that the exact contents of code info strings are highly implementation dependent and they may change arbi... | python.library.dis#dis.code_info |
dis.dis(x=None, *, file=None, depth=None)
Disassemble the x object. x can denote either a module, a class, a method, a function, a generator, an asynchronous generator, a coroutine, a code object, a string of source code or a byte sequence of raw bytecode. For a module, it disassembles all functions. For a class, it ... | python.library.dis#dis.dis |
dis.disassemble(code, lasti=-1, *, file=None)
dis.disco(code, lasti=-1, *, file=None)
Disassemble a code object, indicating the last instruction if lasti was provided. The output is divided in the following columns: the line number, for the first instruction of each line the current instruction, indicated as -->, ... | python.library.dis#dis.disassemble |
dis.disassemble(code, lasti=-1, *, file=None)
dis.disco(code, lasti=-1, *, file=None)
Disassemble a code object, indicating the last instruction if lasti was provided. The output is divided in the following columns: the line number, for the first instruction of each line the current instruction, indicated as -->, ... | python.library.dis#dis.disco |
dis.distb(tb=None, *, file=None)
Disassemble the top-of-stack function of a traceback, using the last traceback if none was passed. The instruction causing the exception is indicated. The disassembly is written as text to the supplied file argument if provided and to sys.stdout otherwise. Changed in version 3.4: Add... | python.library.dis#dis.distb |
dis.findlabels(code)
Detect all offsets in the raw compiled bytecode string code which are jump targets, and return a list of these offsets. | python.library.dis#dis.findlabels |
dis.findlinestarts(code)
This generator function uses the co_firstlineno and co_lnotab attributes of the code object code to find the offsets which are starts of lines in the source code. They are generated as (offset, lineno) pairs. See Objects/lnotab_notes.txt for the co_lnotab format and how to decode it. Changed... | python.library.dis#dis.findlinestarts |
dis.get_instructions(x, *, first_line=None)
Return an iterator over the instructions in the supplied function, method, source code string or code object. The iterator generates a series of Instruction named tuples giving the details of each operation in the supplied code. If first_line is not None, it indicates the l... | python.library.dis#dis.get_instructions |
dis.hascompare
Sequence of bytecodes of Boolean operations. | python.library.dis#dis.hascompare |
dis.hasconst
Sequence of bytecodes that access a constant. | python.library.dis#dis.hasconst |
dis.hasfree
Sequence of bytecodes that access a free variable (note that ‘free’ in this context refers to names in the current scope that are referenced by inner scopes or names in outer scopes that are referenced from this scope. It does not include references to global or builtin scopes). | python.library.dis#dis.hasfree |
dis.hasjabs
Sequence of bytecodes that have an absolute jump target. | python.library.dis#dis.hasjabs |
dis.hasjrel
Sequence of bytecodes that have a relative jump target. | python.library.dis#dis.hasjrel |
dis.haslocal
Sequence of bytecodes that access a local variable. | python.library.dis#dis.haslocal |
dis.hasname
Sequence of bytecodes that access an attribute by name. | python.library.dis#dis.hasname |
class dis.Instruction
Details for a bytecode operation
opcode
numeric code for operation, corresponding to the opcode values listed below and the bytecode values in the Opcode collections.
opname
human readable name for operation
arg
numeric argument to operation (if any), otherwise None
argval
... | python.library.dis#dis.Instruction |
arg
numeric argument to operation (if any), otherwise None | python.library.dis#dis.Instruction.arg |
argrepr
human readable description of operation argument | python.library.dis#dis.Instruction.argrepr |
argval
resolved arg value (if known), otherwise same as arg | python.library.dis#dis.Instruction.argval |
is_jump_target
True if other code jumps to here, otherwise False | python.library.dis#dis.Instruction.is_jump_target |
offset
start index of operation within bytecode sequence | python.library.dis#dis.Instruction.offset |
opcode
numeric code for operation, corresponding to the opcode values listed below and the bytecode values in the Opcode collections. | python.library.dis#dis.Instruction.opcode |
opname
human readable name for operation | python.library.dis#dis.Instruction.opname |
starts_line
line started by this opcode (if any), otherwise None | python.library.dis#dis.Instruction.starts_line |
dis.opmap
Dictionary mapping operation names to bytecodes. | python.library.dis#dis.opmap |
dis.opname
Sequence of operation names, indexable using the bytecode. | python.library.dis#dis.opname |
dis.show_code(x, *, file=None)
Print detailed code object information for the supplied function, method, source code string or code object to file (or sys.stdout if file is not specified). This is a convenient shorthand for print(code_info(x), file=file), intended for interactive exploration at the interpreter prompt... | python.library.dis#dis.show_code |
dis.stack_effect(opcode, oparg=None, *, jump=None)
Compute the stack effect of opcode with argument oparg. If the code has a jump target and jump is True, stack_effect() will return the stack effect of jumping. If jump is False, it will return the stack effect of not jumping. And if jump is None (default), it will re... | python.library.dis#dis.stack_effect |
distutils — Building and installing Python modules The distutils package provides support for building and installing additional modules into a Python installation. The new modules may be either 100%-pure Python, or may be extension modules written in C, or may be collections of Python packages which include modules co... | python.library.distutils |
divmod(a, b)
Take two (non complex) numbers as arguments and return a pair of numbers consisting of their quotient and remainder when using integer division. With mixed operand types, the rules for binary arithmetic operators apply. For integers, the result is the same as (a // b, a % b). For floating point numbers t... | python.library.functions#divmod |
doctest — Test interactive Python examples Source code: Lib/doctest.py The doctest module searches for pieces of text that look like interactive Python sessions, and then executes those sessions to verify that they work exactly as shown. There are several common ways to use doctest: To check that a module’s docstrings... | python.library.doctest |
doctest.COMPARISON_FLAGS
A bitmask or’ing together all the comparison flags above. | python.library.doctest#doctest.COMPARISON_FLAGS |
doctest.debug(module, name, pm=False)
Debug the doctests for an object. The module and name arguments are the same as for function testsource() above. The synthesized Python script for the named object’s docstring is written to a temporary file, and then that file is run under the control of the Python debugger, pdb.... | python.library.doctest#doctest.debug |
class doctest.DebugRunner(checker=None, verbose=None, optionflags=0)
A subclass of DocTestRunner that raises an exception as soon as a failure is encountered. If an unexpected exception occurs, an UnexpectedException exception is raised, containing the test, the example, and the original exception. If the output does... | python.library.doctest#doctest.DebugRunner |
doctest.debug_src(src, pm=False, globs=None)
Debug the doctests in a string. This is like function debug() above, except that a string containing doctest examples is specified directly, via the src argument. Optional argument pm has the same meaning as in function debug() above. Optional argument globs gives a dictio... | python.library.doctest#doctest.debug_src |
doctest.DocFileSuite(*paths, module_relative=True, package=None, setUp=None, tearDown=None, globs=None, optionflags=0, parser=DocTestParser(), encoding=None)
Convert doctest tests from one or more text files to a unittest.TestSuite. The returned unittest.TestSuite is to be run by the unittest framework and runs the i... | python.library.doctest#doctest.DocFileSuite |
class doctest.DocTest(examples, globs, name, filename, lineno, docstring)
A collection of doctest examples that should be run in a single namespace. The constructor arguments are used to initialize the attributes of the same names. DocTest defines the following attributes. They are initialized by the constructor, and... | python.library.doctest#doctest.DocTest |
docstring
The string that the test was extracted from, or None if the string is unavailable, or if the test was not extracted from a string. | python.library.doctest#doctest.DocTest.docstring |
examples
A list of Example objects encoding the individual interactive Python examples that should be run by this test. | python.library.doctest#doctest.DocTest.examples |
filename
The name of the file that this DocTest was extracted from; or None if the filename is unknown, or if the DocTest was not extracted from a file. | python.library.doctest#doctest.DocTest.filename |
globs
The namespace (aka globals) that the examples should be run in. This is a dictionary mapping names to values. Any changes to the namespace made by the examples (such as binding new variables) will be reflected in globs after the test is run. | python.library.doctest#doctest.DocTest.globs |
lineno
The line number within filename where this DocTest begins, or None if the line number is unavailable. This line number is zero-based with respect to the beginning of the file. | python.library.doctest#doctest.DocTest.lineno |
name
A string name identifying the DocTest. Typically, this is the name of the object or file that the test was extracted from. | python.library.doctest#doctest.DocTest.name |
exception doctest.DocTestFailure(test, example, got)
An exception raised by DocTestRunner to signal that a doctest example’s actual output did not match its expected output. The constructor arguments are used to initialize the attributes of the same names. | python.library.doctest#doctest.DocTestFailure |
DocTestFailure.example
The Example that failed. | python.library.doctest#doctest.DocTestFailure.example |
DocTestFailure.got
The example’s actual output. | python.library.doctest#doctest.DocTestFailure.got |
DocTestFailure.test
The DocTest object that was being run when the example failed. | python.library.doctest#doctest.DocTestFailure.test |
class doctest.DocTestFinder(verbose=False, parser=DocTestParser(), recurse=True, exclude_empty=True)
A processing class used to extract the DocTests that are relevant to a given object, from its docstring and the docstrings of its contained objects. DocTests can be extracted from modules, classes, functions, methods,... | python.library.doctest#doctest.DocTestFinder |
find(obj[, name][, module][, globs][, extraglobs])
Return a list of the DocTests that are defined by obj’s docstring, or by any of its contained objects’ docstrings. The optional argument name specifies the object’s name; this name will be used to construct names for the returned DocTests. If name is not specified, t... | python.library.doctest#doctest.DocTestFinder.find |
class doctest.DocTestParser
A processing class used to extract interactive examples from a string, and use them to create a DocTest object. DocTestParser defines the following methods:
get_doctest(string, globs, name, filename, lineno)
Extract all doctest examples from the given string, and collect them into a Do... | python.library.doctest#doctest.DocTestParser |
get_doctest(string, globs, name, filename, lineno)
Extract all doctest examples from the given string, and collect them into a DocTest object. globs, name, filename, and lineno are attributes for the new DocTest object. See the documentation for DocTest for more information. | python.library.doctest#doctest.DocTestParser.get_doctest |
get_examples(string, name='<string>')
Extract all doctest examples from the given string, and return them as a list of Example objects. Line numbers are 0-based. The optional argument name is a name identifying this string, and is only used for error messages. | python.library.doctest#doctest.DocTestParser.get_examples |
parse(string, name='<string>')
Divide the given string into examples and intervening text, and return them as a list of alternating Examples and strings. Line numbers for the Examples are 0-based. The optional argument name is a name identifying this string, and is only used for error messages. | python.library.doctest#doctest.DocTestParser.parse |
class doctest.DocTestRunner(checker=None, verbose=None, optionflags=0)
A processing class used to execute and verify the interactive examples in a DocTest. The comparison between expected outputs and actual outputs is done by an OutputChecker. This comparison may be customized with a number of option flags; see secti... | python.library.doctest#doctest.DocTestRunner |
report_failure(out, test, example, got)
Report that the given example failed. This method is provided to allow subclasses of DocTestRunner to customize their output; it should not be called directly. example is the example about to be processed. got is the actual output from the example. test is the test containing e... | python.library.doctest#doctest.DocTestRunner.report_failure |
report_start(out, test, example)
Report that the test runner is about to process the given example. This method is provided to allow subclasses of DocTestRunner to customize their output; it should not be called directly. example is the example about to be processed. test is the test containing example. out is the ou... | python.library.doctest#doctest.DocTestRunner.report_start |
report_success(out, test, example, got)
Report that the given example ran successfully. This method is provided to allow subclasses of DocTestRunner to customize their output; it should not be called directly. example is the example about to be processed. got is the actual output from the example. test is the test co... | python.library.doctest#doctest.DocTestRunner.report_success |
report_unexpected_exception(out, test, example, exc_info)
Report that the given example raised an unexpected exception. This method is provided to allow subclasses of DocTestRunner to customize their output; it should not be called directly. example is the example about to be processed. exc_info is a tuple containing... | python.library.doctest#doctest.DocTestRunner.report_unexpected_exception |
run(test, compileflags=None, out=None, clear_globs=True)
Run the examples in test (a DocTest object), and display the results using the writer function out. The examples are run in the namespace test.globs. If clear_globs is true (the default), then this namespace will be cleared after the test runs, to help with gar... | python.library.doctest#doctest.DocTestRunner.run |
summarize(verbose=None)
Print a summary of all the test cases that have been run by this DocTestRunner, and return a named tuple TestResults(failed, attempted). The optional verbose argument controls how detailed the summary is. If the verbosity is not specified, then the DocTestRunner’s verbosity is used. | python.library.doctest#doctest.DocTestRunner.summarize |
doctest.DocTestSuite(module=None, globs=None, extraglobs=None, test_finder=None, setUp=None, tearDown=None, checker=None)
Convert doctest tests for a module to a unittest.TestSuite. The returned unittest.TestSuite is to be run by the unittest framework and runs each doctest in the module. If any of the doctests fail,... | python.library.doctest#doctest.DocTestSuite |
doctest.DONT_ACCEPT_BLANKLINE
By default, if an expected output block contains a line containing only the string <BLANKLINE>, then that line will match a blank line in the actual output. Because a genuinely blank line delimits the expected output, this is the only way to communicate that a blank line is expected. Whe... | python.library.doctest#doctest.DONT_ACCEPT_BLANKLINE |
doctest.DONT_ACCEPT_TRUE_FOR_1
By default, if an expected output block contains just 1, an actual output block containing just 1 or just True is considered to be a match, and similarly for 0 versus False. When DONT_ACCEPT_TRUE_FOR_1 is specified, neither substitution is allowed. The default behavior caters to that Py... | python.library.doctest#doctest.DONT_ACCEPT_TRUE_FOR_1 |
doctest.ELLIPSIS
When specified, an ellipsis marker (...) in the expected output can match any substring in the actual output. This includes substrings that span line boundaries, and empty substrings, so it’s best to keep usage of this simple. Complicated uses can lead to the same kinds of “oops, it matched too much!... | python.library.doctest#doctest.ELLIPSIS |
class doctest.Example(source, want, exc_msg=None, lineno=0, indent=0, options=None)
A single interactive example, consisting of a Python statement and its expected output. The constructor arguments are used to initialize the attributes of the same names. Example defines the following attributes. They are initialized ... | python.library.doctest#doctest.Example |
exc_msg
The exception message generated by the example, if the example is expected to generate an exception; or None if it is not expected to generate an exception. This exception message is compared against the return value of traceback.format_exception_only(). exc_msg ends with a newline unless it’s None. The const... | python.library.doctest#doctest.Example.exc_msg |
indent
The example’s indentation in the containing string, i.e., the number of space characters that precede the example’s first prompt. | python.library.doctest#doctest.Example.indent |
lineno
The line number within the string containing this example where the example begins. This line number is zero-based with respect to the beginning of the containing string. | python.library.doctest#doctest.Example.lineno |
options
A dictionary mapping from option flags to True or False, which is used to override default options for this example. Any option flags not contained in this dictionary are left at their default value (as specified by the DocTestRunner’s optionflags). By default, no options are set. | python.library.doctest#doctest.Example.options |
source
A string containing the example’s source code. This source code consists of a single Python statement, and always ends with a newline; the constructor adds a newline when necessary. | python.library.doctest#doctest.Example.source |
want
The expected output from running the example’s source code (either from stdout, or a traceback in case of exception). want ends with a newline unless no output is expected, in which case it’s an empty string. The constructor adds a newline when necessary. | python.library.doctest#doctest.Example.want |
doctest.FAIL_FAST
When specified, exit after the first failing example and don’t attempt to run the remaining examples. Thus, the number of failures reported will be at most 1. This flag may be useful during debugging, since examples after the first failure won’t even produce debugging output. The doctest command lin... | python.library.doctest#doctest.FAIL_FAST |
doctest.IGNORE_EXCEPTION_DETAIL
When specified, an example that expects an exception passes if an exception of the expected type is raised, even if the exception detail does not match. For example, an example expecting ValueError: 42 will pass if the actual exception raised is ValueError: 3*14, but will fail, e.g., i... | python.library.doctest#doctest.IGNORE_EXCEPTION_DETAIL |
doctest.NORMALIZE_WHITESPACE
When specified, all sequences of whitespace (blanks and newlines) are treated as equal. Any sequence of whitespace within the expected output will match any sequence of whitespace within the actual output. By default, whitespace must match exactly. NORMALIZE_WHITESPACE is especially usefu... | python.library.doctest#doctest.NORMALIZE_WHITESPACE |
class doctest.OutputChecker
A class used to check the whether the actual output from a doctest example matches the expected output. OutputChecker defines two methods: check_output(), which compares a given pair of outputs, and returns True if they match; and output_difference(), which returns a string describing the ... | python.library.doctest#doctest.OutputChecker |
check_output(want, got, optionflags)
Return True iff the actual output from an example (got) matches the expected output (want). These strings are always considered to match if they are identical; but depending on what option flags the test runner is using, several non-exact match types are also possible. See section... | python.library.doctest#doctest.OutputChecker.check_output |
output_difference(example, got, optionflags)
Return a string describing the differences between the expected output for a given example (example) and the actual output (got). optionflags is the set of option flags used to compare want and got. | python.library.doctest#doctest.OutputChecker.output_difference |
doctest.register_optionflag(name)
Create a new option flag with a given name, and return the new flag’s integer value. register_optionflag() can be used when subclassing OutputChecker or DocTestRunner to create new options that are supported by your subclasses. register_optionflag() should always be called using the ... | python.library.doctest#doctest.register_optionflag |
doctest.REPORTING_FLAGS
A bitmask or’ing together all the reporting flags above. | python.library.doctest#doctest.REPORTING_FLAGS |
doctest.REPORT_CDIFF
When specified, failures that involve multi-line expected and actual outputs will be displayed using a context diff. | python.library.doctest#doctest.REPORT_CDIFF |
doctest.REPORT_NDIFF
When specified, differences are computed by difflib.Differ, using the same algorithm as the popular ndiff.py utility. This is the only method that marks differences within lines as well as across lines. For example, if a line of expected output contains digit 1 where actual output contains letter... | python.library.doctest#doctest.REPORT_NDIFF |
doctest.REPORT_ONLY_FIRST_FAILURE
When specified, display the first failing example in each doctest, but suppress output for all remaining examples. This will prevent doctest from reporting correct examples that break because of earlier failures; but it might also hide incorrect examples that fail independently of th... | python.library.doctest#doctest.REPORT_ONLY_FIRST_FAILURE |
doctest.REPORT_UDIFF
When specified, failures that involve multi-line expected and actual outputs are displayed using a unified diff. | python.library.doctest#doctest.REPORT_UDIFF |
doctest.run_docstring_examples(f, globs, verbose=False, name="NoName", compileflags=None, optionflags=0)
Test examples associated with object f; for example, f may be a string, a module, a function, or a class object. A shallow copy of dictionary argument globs is used for the execution context. Optional argument nam... | python.library.doctest#doctest.run_docstring_examples |
doctest.script_from_examples(s)
Convert text with examples to a script. Argument s is a string containing doctest examples. The string is converted to a Python script, where doctest examples in s are converted to regular code, and everything else is converted to Python comments. The generated script is returned as a ... | python.library.doctest#doctest.script_from_examples |
doctest.set_unittest_reportflags(flags)
Set the doctest reporting flags to use. Argument flags takes the bitwise OR of option flags. See section Option Flags. Only “reporting flags” can be used. This is a module-global setting, and affects all future doctests run by module unittest: the runTest() method of DocTestCas... | python.library.doctest#doctest.set_unittest_reportflags |
doctest.SKIP
When specified, do not run the example at all. This can be useful in contexts where doctest examples serve as both documentation and test cases, and an example should be included for documentation purposes, but should not be checked. E.g., the example’s output might be random; or the example might depend... | python.library.doctest#doctest.SKIP |
doctest.testfile(filename, module_relative=True, name=None, package=None, globs=None, verbose=None, report=True, optionflags=0, extraglobs=None, raise_on_error=False, parser=DocTestParser(), encoding=None)
All arguments except filename are optional, and should be specified in keyword form. Test examples in the file n... | python.library.doctest#doctest.testfile |
doctest.testmod(m=None, name=None, globs=None, verbose=None, report=True, optionflags=0, extraglobs=None, raise_on_error=False, exclude_empty=False)
All arguments are optional, and all except for m should be specified in keyword form. Test examples in docstrings in functions and classes reachable from module m (or mo... | python.library.doctest#doctest.testmod |
doctest.testsource(module, name)
Convert the doctest for an object to a script. Argument module is a module object, or dotted name of a module, containing the object whose doctests are of interest. Argument name is the name (within the module) of the object with the doctests of interest. The result is a string, conta... | python.library.doctest#doctest.testsource |
exception doctest.UnexpectedException(test, example, exc_info)
An exception raised by DocTestRunner to signal that a doctest example raised an unexpected exception. The constructor arguments are used to initialize the attributes of the same names. | python.library.doctest#doctest.UnexpectedException |
UnexpectedException.example
The Example that failed. | python.library.doctest#doctest.UnexpectedException.example |
UnexpectedException.exc_info
A tuple containing information about the unexpected exception, as returned by sys.exc_info(). | python.library.doctest#doctest.UnexpectedException.exc_info |
UnexpectedException.test
The DocTest object that was being run when the example failed. | python.library.doctest#doctest.UnexpectedException.test |
Ellipsis
The same as the ellipsis literal “...”. Special value used mostly in conjunction with extended slicing syntax for user-defined container data types. | python.library.constants#Ellipsis |
email — An email and MIME handling package Source code: Lib/email/__init__.py The email package is a library for managing email messages. It is specifically not designed to do any sending of email messages to SMTP (RFC 2821), NNTP, or other servers; those are functions of modules such as smtplib and nntplib. The email ... | python.library.email |
email.charset.add_alias(alias, canonical)
Add a character set alias. alias is the alias name, e.g. latin-1. canonical is the character set’s canonical name, e.g. iso-8859-1. The global charset alias registry is kept in the module global dictionary ALIASES. | python.library.email.charset#email.charset.add_alias |
email.charset.add_charset(charset, header_enc=None, body_enc=None, output_charset=None)
Add character properties to the global registry. charset is the input character set, and must be the canonical name of a character set. Optional header_enc and body_enc is either Charset.QP for quoted-printable, Charset.BASE64 for... | python.library.email.charset#email.charset.add_charset |
email.charset.add_codec(charset, codecname)
Add a codec that map characters in the given character set to and from Unicode. charset is the canonical name of a character set. codecname is the name of a Python codec, as appropriate for the second argument to the str’s encode() method. | python.library.email.charset#email.charset.add_codec |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.