doc_content stringlengths 1 386k | doc_id stringlengths 5 188 |
|---|---|
max(other, context=None)
Like max(self, other) except that the context rounding rule is applied before returning and that NaN values are either signaled or ignored (depending on the context and whether they are signaling or quiet). | python.library.decimal#decimal.Decimal.max |
max_mag(other, context=None)
Similar to the max() method, but the comparison is done using the absolute values of the operands. | python.library.decimal#decimal.Decimal.max_mag |
min(other, context=None)
Like min(self, other) except that the context rounding rule is applied before returning and that NaN values are either signaled or ignored (depending on the context and whether they are signaling or quiet). | python.library.decimal#decimal.Decimal.min |
min_mag(other, context=None)
Similar to the min() method, but the comparison is done using the absolute values of the operands. | python.library.decimal#decimal.Decimal.min_mag |
next_minus(context=None)
Return the largest number representable in the given context (or in the current thread’s context if no context is given) that is smaller than the given operand. | python.library.decimal#decimal.Decimal.next_minus |
next_plus(context=None)
Return the smallest number representable in the given context (or in the current thread’s context if no context is given) that is larger than the given operand. | python.library.decimal#decimal.Decimal.next_plus |
next_toward(other, context=None)
If the two operands are unequal, return the number closest to the first operand in the direction of the second operand. If both operands are numerically equal, return a copy of the first operand with the sign set to be the same as the sign of the second operand. | python.library.decimal#decimal.Decimal.next_toward |
normalize(context=None)
Normalize the number by stripping the rightmost trailing zeros and converting any result equal to Decimal('0') to Decimal('0e0'). Used for producing canonical values for attributes of an equivalence class. For example, Decimal('32.100') and Decimal('0.321000e+2') both normalize to the equivale... | python.library.decimal#decimal.Decimal.normalize |
number_class(context=None)
Return a string describing the class of the operand. The returned value is one of the following ten strings.
"-Infinity", indicating that the operand is negative infinity.
"-Normal", indicating that the operand is a negative normal number.
"-Subnormal", indicating that the operand is ne... | python.library.decimal#decimal.Decimal.number_class |
quantize(exp, rounding=None, context=None)
Return a value equal to the first operand after rounding and having the exponent of the second operand. >>> Decimal('1.41421356').quantize(Decimal('1.000'))
Decimal('1.414')
Unlike other operations, if the length of the coefficient after the quantize operation would be grea... | python.library.decimal#decimal.Decimal.quantize |
radix()
Return Decimal(10), the radix (base) in which the Decimal class does all its arithmetic. Included for compatibility with the specification. | python.library.decimal#decimal.Decimal.radix |
remainder_near(other, context=None)
Return the remainder from dividing self by other. This differs from self % other in that the sign of the remainder is chosen so as to minimize its absolute value. More precisely, the return value is self - n * other where n is the integer nearest to the exact value of self / other,... | python.library.decimal#decimal.Decimal.remainder_near |
rotate(other, context=None)
Return the result of rotating the digits of the first operand by an amount specified by the second operand. The second operand must be an integer in the range -precision through precision. The absolute value of the second operand gives the number of places to rotate. If the second operand ... | python.library.decimal#decimal.Decimal.rotate |
same_quantum(other, context=None)
Test whether self and other have the same exponent or whether both are NaN. This operation is unaffected by context and is quiet: no flags are changed and no rounding is performed. As an exception, the C version may raise InvalidOperation if the second operand cannot be converted exa... | python.library.decimal#decimal.Decimal.same_quantum |
scaleb(other, context=None)
Return the first operand with exponent adjusted by the second. Equivalently, return the first operand multiplied by 10**other. The second operand must be an integer. | python.library.decimal#decimal.Decimal.scaleb |
shift(other, context=None)
Return the result of shifting the digits of the first operand by an amount specified by the second operand. The second operand must be an integer in the range -precision through precision. The absolute value of the second operand gives the number of places to shift. If the second operand is... | python.library.decimal#decimal.Decimal.shift |
sqrt(context=None)
Return the square root of the argument to full precision. | python.library.decimal#decimal.Decimal.sqrt |
to_eng_string(context=None)
Convert to a string, using engineering notation if an exponent is needed. Engineering notation has an exponent which is a multiple of 3. This can leave up to 3 digits to the left of the decimal place and may require the addition of either one or two trailing zeros. For example, this conver... | python.library.decimal#decimal.Decimal.to_eng_string |
to_integral(rounding=None, context=None)
Identical to the to_integral_value() method. The to_integral name has been kept for compatibility with older versions. | python.library.decimal#decimal.Decimal.to_integral |
to_integral_exact(rounding=None, context=None)
Round to the nearest integer, signaling Inexact or Rounded as appropriate if rounding occurs. The rounding mode is determined by the rounding parameter if given, else by the given context. If neither parameter is given then the rounding mode of the current context is use... | python.library.decimal#decimal.Decimal.to_integral_exact |
to_integral_value(rounding=None, context=None)
Round to the nearest integer without signaling Inexact or Rounded. If given, applies rounding; otherwise, uses the rounding method in either the supplied context or the current context. | python.library.decimal#decimal.Decimal.to_integral_value |
class decimal.DecimalException
Base class for other signals and a subclass of ArithmeticError. | python.library.decimal#decimal.DecimalException |
class decimal.DefaultContext
This context is used by the Context constructor as a prototype for new contexts. Changing a field (such a precision) has the effect of changing the default for new contexts created by the Context constructor. This context is most useful in multi-threaded environments. Changing one of the ... | python.library.decimal#decimal.DefaultContext |
class decimal.DivisionByZero
Signals the division of a non-infinite number by zero. Can occur with division, modulo division, or when raising a number to a negative power. If this signal is not trapped, returns Infinity or -Infinity with the sign determined by the inputs to the calculation. | python.library.decimal#decimal.DivisionByZero |
class decimal.ExtendedContext
This is a standard context defined by the General Decimal Arithmetic Specification. Precision is set to nine. Rounding is set to ROUND_HALF_EVEN. All flags are cleared. No traps are enabled (so that exceptions are not raised during computations). Because the traps are disabled, this cont... | python.library.decimal#decimal.ExtendedContext |
class decimal.FloatOperation
Enable stricter semantics for mixing floats and Decimals. If the signal is not trapped (default), mixing floats and Decimals is permitted in the Decimal constructor, create_decimal() and all comparison operators. Both conversion and comparisons are exact. Any occurrence of a mixed operati... | python.library.decimal#decimal.FloatOperation |
decimal.getcontext()
Return the current context for the active thread. | python.library.decimal#decimal.getcontext |
decimal.HAVE_CONTEXTVAR
The default value is True. If Python is compiled --without-decimal-contextvar, the C version uses a thread-local rather than a coroutine-local context and the value is False. This is slightly faster in some nested context scenarios. | python.library.decimal#decimal.HAVE_CONTEXTVAR |
decimal.HAVE_THREADS
The value is True. Deprecated, because Python now always has threads. | python.library.decimal#decimal.HAVE_THREADS |
class decimal.Inexact
Indicates that rounding occurred and the result is not exact. Signals when non-zero digits were discarded during rounding. The rounded result is returned. The signal flag or trap is used to detect when results are inexact. | python.library.decimal#decimal.Inexact |
class decimal.InvalidOperation
An invalid operation was performed. Indicates that an operation was requested that does not make sense. If not trapped, returns NaN. Possible causes include: Infinity - Infinity
0 * Infinity
Infinity / Infinity
x % 0
Infinity % x
sqrt(-x) and x > 0
0 ** 0
x ** (non-integer)
x ** Infinit... | python.library.decimal#decimal.InvalidOperation |
decimal.localcontext(ctx=None)
Return a context manager that will set the current context for the active thread to a copy of ctx on entry to the with-statement and restore the previous context when exiting the with-statement. If no context is specified, a copy of the current context is used. For example, the followin... | python.library.decimal#decimal.localcontext |
decimal.MAX_EMAX | python.library.decimal#decimal.MAX_EMAX |
decimal.MAX_PREC | python.library.decimal#decimal.MAX_PREC |
decimal.MIN_EMIN | python.library.decimal#decimal.MIN_EMIN |
decimal.MIN_ETINY | python.library.decimal#decimal.MIN_ETINY |
class decimal.Overflow
Numerical overflow. Indicates the exponent is larger than Emax after rounding has occurred. If not trapped, the result depends on the rounding mode, either pulling inward to the largest representable finite number or rounding outward to Infinity. In either case, Inexact and Rounded are also sig... | python.library.decimal#decimal.Overflow |
class decimal.Rounded
Rounding occurred though possibly no information was lost. Signaled whenever rounding discards digits; even if those digits are zero (such as rounding 5.00 to 5.0). If not trapped, returns the result unchanged. This signal is used to detect loss of significant digits. | python.library.decimal#decimal.Rounded |
decimal.ROUND_05UP
Round away from zero if last digit after rounding towards zero would have been 0 or 5; otherwise round towards zero. | python.library.decimal#decimal.ROUND_05UP |
decimal.ROUND_CEILING
Round towards Infinity. | python.library.decimal#decimal.ROUND_CEILING |
decimal.ROUND_DOWN
Round towards zero. | python.library.decimal#decimal.ROUND_DOWN |
decimal.ROUND_FLOOR
Round towards -Infinity. | python.library.decimal#decimal.ROUND_FLOOR |
decimal.ROUND_HALF_DOWN
Round to nearest with ties going towards zero. | python.library.decimal#decimal.ROUND_HALF_DOWN |
decimal.ROUND_HALF_EVEN
Round to nearest with ties going to nearest even integer. | python.library.decimal#decimal.ROUND_HALF_EVEN |
decimal.ROUND_HALF_UP
Round to nearest with ties going away from zero. | python.library.decimal#decimal.ROUND_HALF_UP |
decimal.ROUND_UP
Round away from zero. | python.library.decimal#decimal.ROUND_UP |
decimal.setcontext(c)
Set the current context for the active thread to c. | python.library.decimal#decimal.setcontext |
class decimal.Subnormal
Exponent was lower than Emin prior to rounding. Occurs when an operation result is subnormal (the exponent is too small). If not trapped, returns the result unchanged. | python.library.decimal#decimal.Subnormal |
class decimal.Underflow
Numerical underflow with result rounded to zero. Occurs when a subnormal result is pushed to zero by rounding. Inexact and Subnormal are also signaled. | python.library.decimal#decimal.Underflow |
definition.__name__
The name of the class, function, method, descriptor, or generator instance. | python.library.stdtypes#definition.__name__ |
definition.__qualname__
The qualified name of the class, function, method, descriptor, or generator instance. New in version 3.3. | python.library.stdtypes#definition.__qualname__ |
delattr(object, name)
This is a relative of setattr(). The arguments are an object and a string. The string must be the name of one of the object’s attributes. The function deletes the named attribute, provided the object allows it. For example, delattr(x, 'foobar') is equivalent to del x.foobar. | python.library.functions#delattr |
exception DeprecationWarning
Base class for warnings about deprecated features when those warnings are intended for other Python developers. Ignored by the default warning filters, except in the __main__ module (PEP 565). Enabling the Python Development Mode shows this warning. | python.library.exceptions#DeprecationWarning |
class dict(**kwarg)
class dict(mapping, **kwarg)
class dict(iterable, **kwarg)
Create a new dictionary. The dict object is the dictionary class. See dict and Mapping Types — dict for documentation about this class. For other containers see the built-in list, set, and tuple classes, as well as the collections modu... | python.library.functions#dict |
class dict(**kwarg)
class dict(mapping, **kwarg)
class dict(iterable, **kwarg)
Return a new dictionary initialized from an optional positional argument and a possibly empty set of keyword arguments. Dictionaries can be created by several means: Use a comma-separated list of key: value pairs within braces: {'jack... | python.library.stdtypes#dict |
clear()
Remove all items from the dictionary. | python.library.stdtypes#dict.clear |
copy()
Return a shallow copy of the dictionary. | python.library.stdtypes#dict.copy |
classmethod fromkeys(iterable[, value])
Create a new dictionary with keys from iterable and values set to value. fromkeys() is a class method that returns a new dictionary. value defaults to None. All of the values refer to just a single instance, so it generally doesn’t make sense for value to be a mutable object su... | python.library.stdtypes#dict.fromkeys |
get(key[, default])
Return the value for key if key is in the dictionary, else default. If default is not given, it defaults to None, so that this method never raises a KeyError. | python.library.stdtypes#dict.get |
items()
Return a new view of the dictionary’s items ((key, value) pairs). See the documentation of view objects. | python.library.stdtypes#dict.items |
keys()
Return a new view of the dictionary’s keys. See the documentation of view objects. | python.library.stdtypes#dict.keys |
pop(key[, default])
If key is in the dictionary, remove it and return its value, else return default. If default is not given and key is not in the dictionary, a KeyError is raised. | python.library.stdtypes#dict.pop |
popitem()
Remove and return a (key, value) pair from the dictionary. Pairs are returned in LIFO order. popitem() is useful to destructively iterate over a dictionary, as often used in set algorithms. If the dictionary is empty, calling popitem() raises a KeyError. Changed in version 3.7: LIFO order is now guaranteed... | python.library.stdtypes#dict.popitem |
setdefault(key[, default])
If key is in the dictionary, return its value. If not, insert key with a value of default and return default. default defaults to None. | python.library.stdtypes#dict.setdefault |
update([other])
Update the dictionary with the key/value pairs from other, overwriting existing keys. Return None. update() accepts either another dictionary object or an iterable of key/value pairs (as tuples or other iterables of length two). If keyword arguments are specified, the dictionary is then updated with t... | python.library.stdtypes#dict.update |
values()
Return a new view of the dictionary’s values. See the documentation of view objects. An equality comparison between one dict.values() view and another will always return False. This also applies when comparing dict.values() to itself: >>> d = {'a': 1}
>>> d.values() == d.values()
False | python.library.stdtypes#dict.values |
difflib — Helpers for computing deltas Source code: Lib/difflib.py This module provides classes and functions for comparing sequences. It can be used for example, for comparing files, and can produce information about file differences in various formats, including HTML and context and unified diffs. For comparing direc... | python.library.difflib |
difflib.context_diff(a, b, fromfile='', tofile='', fromfiledate='', tofiledate='', n=3, lineterm='\n')
Compare a and b (lists of strings); return a delta (a generator generating the delta lines) in context diff format. Context diffs are a compact way of showing just the lines that have changed plus a few lines of con... | python.library.difflib#difflib.context_diff |
class difflib.Differ
This is a class for comparing sequences of lines of text, and producing human-readable differences or deltas. Differ uses SequenceMatcher both to compare sequences of lines, and to compare sequences of characters within similar (near-matching) lines. Each line of a Differ delta begins with a two-... | python.library.difflib#difflib.Differ |
compare(a, b)
Compare two sequences of lines, and generate the delta (a sequence of lines). Each sequence must contain individual single-line strings ending with newlines. Such sequences can be obtained from the readlines() method of file-like objects. The delta generated also consists of newline-terminated strings, ... | python.library.difflib#difflib.Differ.compare |
difflib.diff_bytes(dfunc, a, b, fromfile=b'', tofile=b'', fromfiledate=b'', tofiledate=b'', n=3, lineterm=b'\n')
Compare a and b (lists of bytes objects) using dfunc; yield a sequence of delta lines (also bytes) in the format returned by dfunc. dfunc must be a callable, typically either unified_diff() or context_diff... | python.library.difflib#difflib.diff_bytes |
difflib.get_close_matches(word, possibilities, n=3, cutoff=0.6)
Return a list of the best “good enough” matches. word is a sequence for which close matches are desired (typically a string), and possibilities is a list of sequences against which to match word (typically a list of strings). Optional argument n (default... | python.library.difflib#difflib.get_close_matches |
class difflib.HtmlDiff
This class can be used to create an HTML table (or a complete HTML file containing the table) showing a side by side, line by line comparison of text with inter-line and intra-line change highlights. The table can be generated in either full or contextual difference mode. The constructor for th... | python.library.difflib#difflib.HtmlDiff |
make_file(fromlines, tolines, fromdesc='', todesc='', context=False, numlines=5, *, charset='utf-8')
Compares fromlines and tolines (lists of strings) and returns a string which is a complete HTML file containing a table showing line by line differences with inter-line and intra-line changes highlighted. fromdesc and... | python.library.difflib#difflib.HtmlDiff.make_file |
make_table(fromlines, tolines, fromdesc='', todesc='', context=False, numlines=5)
Compares fromlines and tolines (lists of strings) and returns a string which is a complete HTML table showing line by line differences with inter-line and intra-line changes highlighted. The arguments for this method are the same as tho... | python.library.difflib#difflib.HtmlDiff.make_table |
__init__(tabsize=8, wrapcolumn=None, linejunk=None, charjunk=IS_CHARACTER_JUNK)
Initializes instance of HtmlDiff. tabsize is an optional keyword argument to specify tab stop spacing and defaults to 8. wrapcolumn is an optional keyword to specify column number where lines are broken and wrapped, defaults to None where... | python.library.difflib#difflib.HtmlDiff.__init__ |
difflib.IS_CHARACTER_JUNK(ch)
Return True for ignorable characters. The character ch is ignorable if ch is a space or tab, otherwise it is not ignorable. Used as a default for parameter charjunk in ndiff(). | python.library.difflib#difflib.IS_CHARACTER_JUNK |
difflib.IS_LINE_JUNK(line)
Return True for ignorable lines. The line line is ignorable if line is blank or contains a single '#', otherwise it is not ignorable. Used as a default for parameter linejunk in ndiff() in older versions. | python.library.difflib#difflib.IS_LINE_JUNK |
difflib.ndiff(a, b, linejunk=None, charjunk=IS_CHARACTER_JUNK)
Compare a and b (lists of strings); return a Differ-style delta (a generator generating the delta lines). Optional keyword parameters linejunk and charjunk are filtering functions (or None): linejunk: A function that accepts a single string argument, and ... | python.library.difflib#difflib.ndiff |
difflib.restore(sequence, which)
Return one of the two sequences that generated a delta. Given a sequence produced by Differ.compare() or ndiff(), extract lines originating from file 1 or 2 (parameter which), stripping off line prefixes. Example: >>> diff = ndiff('one\ntwo\nthree\n'.splitlines(keepends=True),
... ... | python.library.difflib#difflib.restore |
class difflib.SequenceMatcher(isjunk=None, a='', b='', autojunk=True)
Optional argument isjunk must be None (the default) or a one-argument function that takes a sequence element and returns true if and only if the element is “junk” and should be ignored. Passing None for isjunk is equivalent to passing lambda x: Fal... | python.library.difflib#difflib.SequenceMatcher |
find_longest_match(alo=0, ahi=None, blo=0, bhi=None)
Find longest matching block in a[alo:ahi] and b[blo:bhi]. If isjunk was omitted or None, find_longest_match() returns (i, j, k) such that a[i:i+k] is equal to b[j:j+k], where alo
<= i <= i+k <= ahi and blo <= j <= j+k <= bhi. For all (i', j',
k') meeting those cond... | python.library.difflib#difflib.SequenceMatcher.find_longest_match |
get_grouped_opcodes(n=3)
Return a generator of groups with up to n lines of context. Starting with the groups returned by get_opcodes(), this method splits out smaller change clusters and eliminates intervening ranges which have no changes. The groups are returned in the same format as get_opcodes(). | python.library.difflib#difflib.SequenceMatcher.get_grouped_opcodes |
get_matching_blocks()
Return list of triples describing non-overlapping matching subsequences. Each triple is of the form (i, j, n), and means that a[i:i+n] == b[j:j+n]. The triples are monotonically increasing in i and j. The last triple is a dummy, and has the value (len(a), len(b), 0). It is the only triple with n... | python.library.difflib#difflib.SequenceMatcher.get_matching_blocks |
get_opcodes()
Return list of 5-tuples describing how to turn a into b. Each tuple is of the form (tag, i1, i2, j1, j2). The first tuple has i1 == j1 ==
0, and remaining tuples have i1 equal to the i2 from the preceding tuple, and, likewise, j1 equal to the previous j2. The tag values are strings, with these meanings:... | python.library.difflib#difflib.SequenceMatcher.get_opcodes |
quick_ratio()
Return an upper bound on ratio() relatively quickly. | python.library.difflib#difflib.SequenceMatcher.quick_ratio |
ratio()
Return a measure of the sequences’ similarity as a float in the range [0, 1]. Where T is the total number of elements in both sequences, and M is the number of matches, this is 2.0*M / T. Note that this is 1.0 if the sequences are identical, and 0.0 if they have nothing in common. This is expensive to compute... | python.library.difflib#difflib.SequenceMatcher.ratio |
real_quick_ratio()
Return an upper bound on ratio() very quickly. | python.library.difflib#difflib.SequenceMatcher.real_quick_ratio |
set_seq1(a)
Set the first sequence to be compared. The second sequence to be compared is not changed. | python.library.difflib#difflib.SequenceMatcher.set_seq1 |
set_seq2(b)
Set the second sequence to be compared. The first sequence to be compared is not changed. | python.library.difflib#difflib.SequenceMatcher.set_seq2 |
set_seqs(a, b)
Set the two sequences to be compared. | python.library.difflib#difflib.SequenceMatcher.set_seqs |
difflib.unified_diff(a, b, fromfile='', tofile='', fromfiledate='', tofiledate='', n=3, lineterm='\n')
Compare a and b (lists of strings); return a delta (a generator generating the delta lines) in unified diff format. Unified diffs are a compact way of showing just the lines that have changed plus a few lines of con... | python.library.difflib#difflib.unified_diff |
dir([object])
Without arguments, return the list of names in the current local scope. With an argument, attempt to return a list of valid attributes for that object. If the object has a method named __dir__(), this method will be called and must return the list of attributes. This allows objects that implement a cust... | python.library.functions#dir |
dis — Disassembler for Python bytecode Source code: Lib/dis.py The dis module supports the analysis of CPython bytecode by disassembling it. The CPython bytecode which this module takes as an input is defined in the file Include/opcode.h and used by the compiler and the interpreter. CPython implementation detail: Byte... | python.library.dis |
class dis.Bytecode(x, *, first_line=None, current_offset=None)
Analyse the bytecode corresponding to a function, generator, asynchronous generator, coroutine, method, string of source code, or a code object (as returned by compile()). This is a convenience wrapper around many of the functions listed below, most notab... | python.library.dis#dis.Bytecode |
codeobj
The compiled code object. | python.library.dis#dis.Bytecode.codeobj |
dis()
Return a formatted view of the bytecode operations (the same as printed by dis.dis(), but returned as a multi-line string). | python.library.dis#dis.Bytecode.dis |
first_line
The first source line of the code object (if available) | python.library.dis#dis.Bytecode.first_line |
classmethod from_traceback(tb)
Construct a Bytecode instance from the given traceback, setting current_offset to the instruction responsible for the exception. | python.library.dis#dis.Bytecode.from_traceback |
info()
Return a formatted multi-line string with detailed information about the code object, like code_info(). | python.library.dis#dis.Bytecode.info |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.