fractions API Reference
Full documentation for fractions (Standard Library / Native)
fractions.Decimal
Python Library Documentation: class Decimal in module decimal
class Decimal(builtins.object)
| Decimal(value='0', context=None)
|
| Construct a new Decimal object. 'value' can be an integer, string, tuple,
| or another Decimal object. If no value is given, return Decimal('0'). The
| context does not affect the conversion and is only passed to determine if
| the InvalidOperation trap is active.
|
| Methods defined here:
|
| __abs__(self, /)
| abs(self)
|
| __add__(self, value, /)
| Return self+value.
|
| __bool__(self, /)
| True if self else False
|
| __ceil__(...)
|
| __complex__(...)
|
| __copy__(...)
|
| __deepcopy__(...)
|
| __divmod__(self, value, /)
| Return divmod(self, value).
|
| __eq__(self, value, /)
| Return self==value.
|
| __float__(self, /)
| float(self)
|
| __floor__(...)
|
| __floordiv__(self, value, /)
| Return self//value.
|
| __format__(...)
| Default object formatter.
|
| Return str(self) if format_spec is empty. Raise TypeError otherwise.
|
| __ge__(self, value, /)
| Return self>=value.
|
| __getattribute__(self, name, /)
| Return getattr(self, name).
|
| __gt__(self, value, /)
| Return self>value.
|
| __hash__(self, /)
| Return hash(self).
|
| __int__(self, /)
| int(self)
|
| __le__(self, value, /)
| Return self<=value.
|
| __lt__(self, value, /)
| Return self<value.
|
| __mod__(self, value, /)
| Return self%value.
|
| __mul__(self, value, /)
| Return self*value.
|
| __ne__(self, value, /)
| Return self!=value.
|
| __neg__(self, /)
| -self
|
| __pos__(self, /)
| +self
|
| __pow__(self, value, mod=None, /)
| Return pow(self, value, mod).
|
| __radd__(self, value, /)
| Return value+self.
|
| __rdivmod__(self, value, /)
| Return divmod(value, self).
|
| __reduce__(...)
| Helper for pickle.
|
| __repr__(self, /)
| Return repr(self).
|
| __rfloordiv__(self, value, /)
| Return value//self.
|
| __rmod__(self, value, /)
| Return value%self.
|
| __rmul__(self, value, /)
| Return value*self.
|
| __round__(...)
|
| __rpow__(self, value, mod=None, /)
| Return pow(value, self, mod).
|
| __rsub__(self, value, /)
| Return value-self.
|
| __rtruediv__(self, value, /)
| Return value/self.
|
| __sizeof__(...)
| Size of object in memory, in bytes.
|
| __str__(self, /)
| Return str(self).
|
| __sub__(self, value, /)
| Return self-value.
|
| __truediv__(self, value, /)
| Return self/value.
|
| __trunc__(...)
|
| adjusted(self, /)
| Return the adjusted exponent of the number. Defined as exp + digits - 1.
|
| as_integer_ratio(self, /)
| Decimal.as_integer_ratio() -> (int, int)
|
| Return a pair of integers, whose ratio is exactly equal to the original
| Decimal and with a positive denominator. The ratio is in lowest terms.
| Raise OverflowError on infinities and a ValueError on NaNs.
|
| as_tuple(self, /)
| Return a tuple representation of the number.
|
| canonical(self, /)
| Return the canonical encoding of the argument. Currently, the encoding
| of a Decimal instance is always canonical, so this operation returns its
| argument unchanged.
|
| compare(self, /, other, context=None)
| Compare self to other. Return a decimal value:
|
| a or b is a NaN ==> Decimal('NaN')
| a < b ==> Decimal('-1')
| a == b ==> Decimal('0')
| a > b ==> Decimal('1')
|
| compare_signal(self, /, other, context=None)
| Identical to compare, except that all NaNs signal.
|
| compare_total(self, /, other, context=None)
| Compare two operands using their abstract representation rather than
| their numerical value. Similar to the compare() method, but the result
| gives a total ordering on Decimal instances. Two Decimal instances with
| the same numeric value but different representations compare unequal
| in this ordering:
|
| >>> Decimal('12.0').compare_total(Decimal('12'))
| Decimal('-1')
|
| Quiet and signaling NaNs are also included in the total ordering. The result
| of this function is Decimal('0') if both operands have the same representation,
| Decimal('-1') if the first operand is lower in the total order than the second,
| and Decimal('1') if the first operand is higher in the total order than the
| second operand. See the specification for details of the total order.
|
| 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 exactly.
|
| compare_total_mag(self, /, other, context=None)
| Compare two operands using their abstract representation rather than their
| value as in compare_total(), but ignoring the sign of each operand.
|
| x.compare_total_mag(y) is equivalent to x.copy_abs().compare_total(y.copy_abs()).
|
| 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 exactly.
|
| conjugate(self, /)
| Return self.
|
| copy_abs(self, /)
| Return the absolute value of the argument. This operation is unaffected by
| context and is quiet: no flags are changed and no rounding is performed.
|
| copy_negate(self, /)
| Return the negation of the argument. This operation is unaffected by context
| and is quiet: no flags are changed and no rounding is performed.
|
| copy_sign(self, /, other, context=None)
| Return a copy of the first operand with the sign set to be the same as the
| sign of the second operand. For example:
|
| >>> Decimal('2.3').copy_sign(Decimal('-1.5'))
| Decimal('-2.3')
|
| 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 exactly.
|
| exp(self, /, context=None)
| Return the value of the (natural) exponential function e**x at the given
| number. The function always uses the ROUND_HALF_EVEN mode and the result
| is correctly rounded.
|
| fma(self, /, other, third, context=None)
| Fused multiply-add. Return self*other+third with no rounding of the
| intermediate product self*other.
|
| >>> Decimal(2).fma(3, 5)
| Decimal('11')
|
| is_canonical(self, /)
| Return True if the argument is canonical and False otherwise. Currently,
| a Decimal instance is always canonical, so this operation always returns
| True.
|
| is_finite(self, /)
| Return True if the argument is a finite number, and False if the argument
| is infinite or a NaN.
|
| is_infinite(self, /)
| Return True if the argument is either positive or negative infinity and
| False otherwise.
|
| is_nan(self, /)
| Return True if the argument is a (quiet or signaling) NaN and False
| otherwise.
|
| is_normal(self, /, context=None)
| Return True if the argument is a normal finite non-zero number with an
| adjusted exponent greater than or equal to Emin. Return False if the
| argument is zero, subnormal, infinite or a NaN.
|
| is_qnan(self, /)
| Return True if the argument is a quiet NaN, and False otherwise.
|
| is_signed(self, /)
| Return True if the argument has a negative sign and False otherwise.
| Note that both zeros and NaNs can carry signs.
|
| is_snan(self, /)
| Return True if the argument is a signaling NaN and False otherwise.
|
| is_subnormal(self, /, context=None)
| Return True if the argument is subnormal, and False otherwise. A number is
| subnormal if it is non-zero, finite, and has an adjusted exponent less
| than Emin.
|
| is_zero(self, /)
| Return True if the argument is a (positive or negative) zero and False
| otherwise.
|
| ln(self, /, context=None)
| Return the natural (base e) logarithm of the operand. The function always
| uses the ROUND_HALF_EVEN mode and the result is correctly rounded.
|
| log10(self, /, context=None)
| Return the base ten logarithm of the operand. The function always uses the
| ROUND_HALF_EVEN mode and the result is correctly rounded.
|
| logb(self, /, context=None)
| For a non-zero number, return the adjusted exponent of the operand as a
| Decimal instance. If the operand is a zero, then Decimal('-Infinity') is
| returned and the DivisionByZero condition is raised. If the operand is
| an infinity then Decimal('Infinity') is returned.
|
| logical_and(self, /, other, context=None)
| Return the digit-wise 'and' of the two (logical) operands.
|
| logical_invert(self, /, context=None)
| Return the digit-wise inversion of the (logical) operand.
|
| logical_or(self, /, other, context=None)
| Return the digit-wise 'or' of the two (logical) operands.
|
| logical_xor(self, /, other, context=None)
| Return the digit-wise 'exclusive or' of the two (logical) operands.
|
| max(self, /, other, context=None)
| Maximum of self and other. If one operand is a quiet NaN and the other is
| numeric, the numeric operand is returned.
|
| max_mag(self, /, other, context=None)
| Similar to the max() method, but the comparison is done using the absolute
| values of the operands.
|
| min(self, /, other, context=None)
| Minimum of self and other. If one operand is a quiet NaN and the other is
| numeric, the numeric operand is returned.
|
| min_mag(self, /, other, context=None)
| Similar to the min() method, but the comparison is done using the absolute
| values of the operands.
|
| next_minus(self, /, context=None)
| Return the largest number representable in the given context (or in the
| current default context if no context is given) that is smaller than the
| given operand.
|
| next_plus(self, /, context=None)
| Return the smallest number representable in the given context (or in the
| current default context if no context is given) that is larger than the
| given operand.
|
| next_toward(self, /, 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.
|
| normalize(self, /, 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 members of an equivalence class.
| For example, Decimal('32.100') and Decimal('0.321000e+2') both normalize
| to the equivalent value Decimal('32.1').
|
| number_class(self, /, 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 negative and subnormal.
| * '-Zero', indicating that the operand is a negative zero.
| * '+Zero', indicating that the operand is a positive zero.
| * '+Subnormal', indicating that the operand is positive and subnormal.
| * '+Normal', indicating that the operand is a positive normal number.
| * '+Infinity', indicating that the operand is positive infinity.
| * 'NaN', indicating that the operand is a quiet NaN (Not a Number).
| * 'sNaN', indicating that the operand is a signaling NaN.
|
| quantize(self, /, 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 greater than precision, then an InvalidOperation is signaled.
| This guarantees that, unless there is an error condition, the quantized exponent
| is always equal to that of the right-hand operand.
|
| Also unlike other operations, quantize never signals Underflow, even if the
| result is subnormal and inexact.
|
| If the exponent of the second operand is larger than that of the first, then
| rounding may be necessary. In this case, the rounding mode is determined by the
| rounding argument if given, else by the given context argument; if neither
| argument is given, the rounding mode of the current thread's context is used.
|
| radix(self, /)
| Return Decimal(10), the radix (base) in which the Decimal class does
| all its arithmetic. Included for compatibility with the specification.
|
| remainder_near(self, /, 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, and
| if two integers are equally near then the even one is chosen.
|
| If the result is zero then its sign will be the sign of self.
|
| rotate(self, /, 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 is
| positive then rotation is to the left; otherwise rotation is to the right.
| The coefficient of the first operand is padded on the left with zeros to
| length precision if necessary. The sign and exponent of the first operand are
| unchanged.
|
| same_quantum(self, /, 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 exactly.
|
| scaleb(self, /, other, context=None)
| Return the first operand with the exponent adjusted the second. Equivalently,
| return the first operand multiplied by 10**other. The second operand must be
| an integer.
|
| shift(self, /, 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
| positive, then the shift is to the left; otherwise the shift is to the
| right. Digits shifted into the coefficient are zeros. The sign and exponent
| of the first operand are unchanged.
|
| sqrt(self, /, context=None)
| Return the square root of the argument to full precision. The result is
| correctly rounded using the ROUND_HALF_EVEN rounding mode.
|
| to_eng_string(self, /, context=None)
| Convert to an engineering-type string. Engineering notation has an exponent
| which is a multiple of 3, so there are up to 3 digits left of the decimal
| place. For example, Decimal('123E+1') is converted to Decimal('1.23E+3').
|
| The value of context.capitals determines whether the exponent sign is lower
| or upper case. Otherwise, the context does not affect the operation.
|
| to_integral(self, /, rounding=None, context=None)
| Identical to the to_integral_value() method. The to_integral() name has been
| kept for compatibility with older versions.
|
| to_integral_exact(self, /, 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 default context is used.
|
| to_integral_value(self, /, rounding=None, context=None)
| Round to the nearest integer without signaling Inexact or Rounded. 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 default context is used.
|
| ----------------------------------------------------------------------
| Class methods defined here:
|
| from_float(f, /)
| Class method that converts a float to a decimal number, exactly.
| Since 0.1 is not exactly representable in binary floating point,
| Decimal.from_float(0.1) is not the same as Decimal('0.1').
|
| >>> Decimal.from_float(0.1)
| Decimal('0.1000000000000000055511151231257827021181583404541015625')
| >>> Decimal.from_float(float('nan'))
| Decimal('NaN')
| >>> Decimal.from_float(float('inf'))
| Decimal('Infinity')
| >>> Decimal.from_float(float('-inf'))
| Decimal('-Infinity')
|
| ----------------------------------------------------------------------
| Static methods defined here:
|
| __new__(*args, **kwargs)
| Create and return a new object. See help(type) for accurate signature.
|
| ----------------------------------------------------------------------
| Data descriptors defined here:
|
| imag
|
| real
fractions.Fraction
Python Library Documentation: class Fraction in module fractions
class Fraction(numbers.Rational)
| Fraction(numerator=0, denominator=None)
|
| This class implements rational numbers.
|
| In the two-argument form of the constructor, Fraction(8, 6) will
| produce a rational number equivalent to 4/3. Both arguments must
| be Rational. The numerator defaults to 0 and the denominator
| defaults to 1 so that Fraction(3) == 3 and Fraction() == 0.
|
| Fractions can also be constructed from:
|
| - numeric strings similar to those accepted by the
| float constructor (for example, '-2.3' or '1e10')
|
| - strings of the form '123/456'
|
| - float and Decimal instances
|
| - other Rational instances (including integers)
|
| Method resolution order:
| Fraction
| numbers.Rational
| numbers.Real
| numbers.Complex
| numbers.Number
| builtins.object
|
| Methods defined here:
|
| __abs__(a)
| abs(a)
|
| __add__(a, b) from fractions.Fraction._operator_fallbacks.<locals>
| a + b
|
| __bool__(a)
| a != 0
|
| __ceil__(a)
| math.ceil(a)
|
| __copy__(self)
|
| __deepcopy__(self, memo)
|
| __divmod__(a, b) from fractions.Fraction._operator_fallbacks.<locals>
| (a // b, a % b)
|
| __eq__(a, b)
| a == b
|
| __floor__(a)
| math.floor(a)
|
| __floordiv__(a, b) from fractions.Fraction._operator_fallbacks.<locals>
| a // b
|
| __format__(self, format_spec, /)
| Format this fraction according to the given format specification.
|
| __ge__(a, b)
| a >= b
|
| __gt__(a, b)
| a > b
|
| __hash__(self)
| hash(self)
|
| __int__(a, _index=<built-in function index>)
| int(a)
|
| __le__(a, b)
| a <= b
|
| __lt__(a, b)
| a < b
|
| __mod__(a, b) from fractions.Fraction._operator_fallbacks.<locals>
| a % b
|
| __mul__(a, b) from fractions.Fraction._operator_fallbacks.<locals>
| a * b
|
| __neg__(a)
| -a
|
| __pos__(a)
| +a: Coerces a subclass instance to Fraction
|
| __pow__(a, b)
| a ** b
|
| If b is not an integer, the result will be a float or complex
| since roots are generally irrational. If b is an integer, the
| result will be rational.
|
| __radd__(b, a) from fractions.Fraction._operator_fallbacks.<locals>
| a + b
|
| __rdivmod__(b, a) from fractions.Fraction._operator_fallbacks.<locals>
| (a // b, a % b)
|
| __reduce__(self)
| Helper for pickle.
|
| __repr__(self)
| repr(self)
|
| __rfloordiv__(b, a) from fractions.Fraction._operator_fallbacks.<locals>
| a // b
|
| __rmod__(b, a) from fractions.Fraction._operator_fallbacks.<locals>
| a % b
|
| __rmul__(b, a) from fractions.Fraction._operator_fallbacks.<locals>
| a * b
|
| __round__(self, ndigits=None)
| round(self, ndigits)
|
| Rounds half toward even.
|
| __rpow__(b, a)
| a ** b
|
| __rsub__(b, a) from fractions.Fraction._operator_fallbacks.<locals>
| a - b
|
| __rtruediv__(b, a) from fractions.Fraction._operator_fallbacks.<locals>
| a / b
|
| __str__(self)
| str(self)
|
| __sub__(a, b) from fractions.Fraction._operator_fallbacks.<locals>
| a - b
|
| __truediv__(a, b) from fractions.Fraction._operator_fallbacks.<locals>
| a / b
|
| __trunc__(a)
| math.trunc(a)
|
| as_integer_ratio(self)
| Return a pair of integers, whose ratio is equal to the original Fraction.
|
| The ratio is in lowest terms and has a positive denominator.
|
| is_integer(self)
| Return True if the Fraction is an integer.
|
| limit_denominator(self, max_denominator=1000000)
| Closest Fraction to self with denominator at most max_denominator.
|
| >>> Fraction('3.141592653589793').limit_denominator(10)
| Fraction(22, 7)
| >>> Fraction('3.141592653589793').limit_denominator(100)
| Fraction(311, 99)
| >>> Fraction(4321, 8765).limit_denominator(10000)
| Fraction(4321, 8765)
|
| ----------------------------------------------------------------------
| Class methods defined here:
|
| from_decimal(dec)
| Converts a finite Decimal instance to a rational number, exactly.
|
| from_float(f)
| Converts a finite float to a rational number, exactly.
|
| Beware that Fraction.from_float(0.3) != Fraction(3, 10).
|
| ----------------------------------------------------------------------
| Static methods defined here:
|
| __new__(cls, numerator=0, denominator=None)
| Constructs a Rational.
|
| Takes a string like '3/2' or '1.5', another Rational instance, a
| numerator/denominator pair, or a float.
|
| Examples
| --------
|
| >>> Fraction(10, -8)
| Fraction(-5, 4)
| >>> Fraction(Fraction(1, 7), 5)
| Fraction(1, 35)
| >>> Fraction(Fraction(1, 7), Fraction(2, 3))
| Fraction(3, 14)
| >>> Fraction('314')
| Fraction(314, 1)
| >>> Fraction('-35/4')
| Fraction(-35, 4)
| >>> Fraction('3.1415') # conversion from numeric string
| Fraction(6283, 2000)
| >>> Fraction('-47e-2') # string may include a decimal exponent
| Fraction(-47, 100)
| >>> Fraction(1.47) # direct construction from float (exact conversion)
| Fraction(6620291452234629, 4503599627370496)
| >>> Fraction(2.25)
| Fraction(9, 4)
| >>> Fraction(Decimal('1.47'))
| Fraction(147, 100)
|
| ----------------------------------------------------------------------
| Readonly properties defined here:
|
| denominator
|
| numerator
|
| ----------------------------------------------------------------------
| Data and other attributes defined here:
|
| __abstractmethods__ = frozenset()
|
| ----------------------------------------------------------------------
| Methods inherited from numbers.Rational:
|
| __float__(self)
| float(self) = self.numerator / self.denominator
|
| It's important that this conversion use the integer's "true"
| division rather than casting one side to float before dividing
| so that ratios of huge integers convert without overflowing.
|
| ----------------------------------------------------------------------
| Methods inherited from numbers.Real:
|
| __complex__(self)
| complex(self) == complex(float(self), 0)
|
| conjugate(self)
| Conjugate is a no-op for Reals.
|
| ----------------------------------------------------------------------
| Readonly properties inherited from numbers.Real:
|
| imag
| Real numbers have no imaginary component.
|
| real
| Real numbers are their real component.
fractions.functools
Python Library Documentation: module functools
NAME
functools - functools.py - Tools for working with functions and callable objects
MODULE REFERENCE
https://docs.python.org/3.12/library/functools.html
The following documentation is automatically generated from the Python
source files. It may be incomplete, incorrect or include features that
are considered implementation detail and may vary between Python
implementations. When in doubt, consult the module reference at the
location listed above.
CLASSES
builtins.object
cached_property
partial
partialmethod
singledispatchmethod
class cached_property(builtins.object)
| cached_property(func)
|
| Methods defined here:
|
| __get__(self, instance, owner=None)
|
| __init__(self, func)
| Initialize self. See help(type(self)) for accurate signature.
|
| __set_name__(self, owner, name)
|
| ----------------------------------------------------------------------
| Class methods defined here:
|
| __class_getitem__ = GenericAlias(...)
| Represent a PEP 585 generic type
|
| E.g. for t = list[int], t.__origin__ is list and t.__args__ is (int,).
|
| ----------------------------------------------------------------------
| Data descriptors defined here:
|
| __dict__
| dictionary for instance variables
|
| __weakref__
| list of weak references to the object
class partial(builtins.object)
| partial(func, *args, **keywords) - new function with partial application
| of the given arguments and keywords.
|
| Methods defined here:
|
| __call__(self, /, *args, **kwargs)
| Call self as a function.
|
| __delattr__(self, name, /)
| Implement delattr(self, name).
|
| __getattribute__(self, name, /)
| Return getattr(self, name).
|
| __reduce__(...)
| Helper for pickle.
|
| __repr__(self, /)
| Return repr(self).
|
| __setattr__(self, name, value, /)
| Implement setattr(self, name, value).
|
| __setstate__(...)
|
| ----------------------------------------------------------------------
| Class methods defined here:
|
| __class_getitem__(...)
| See PEP 585
|
| ----------------------------------------------------------------------
| Static methods defined here:
|
| __new__(*args, **kwargs)
| Create and return a new object. See help(type) for accurate signature.
|
| ----------------------------------------------------------------------
| Data descriptors defined here:
|
| __dict__
|
| __vectorcalloffset__
|
| args
| tuple of arguments to future partial calls
|
| func
| function object to use in future partial calls
|
| keywords
| dictionary of keyword arguments to future partial calls
class partialmethod(builtins.object)
| partialmethod(func, /, *args, **keywords)
|
| Method descriptor with partial application of the given arguments
| and keywords.
|
| Supports wrapping existing descriptors and handles non-descriptor
| callables as instance methods.
|
| Methods defined here:
|
| __get__(self, obj, cls=None)
|
| __init__(self, func, /, *args, **keywords)
| Initialize self. See help(type(self)) for accurate signature.
|
| __repr__(self)
| Return repr(self).
|
| ----------------------------------------------------------------------
| Class methods defined here:
|
| __class_getitem__ = GenericAlias(...)
| Represent a PEP 585 generic type
|
| E.g. for t = list[int], t.__origin__ is list and t.__args__ is (int,).
|
| ----------------------------------------------------------------------
| Readonly properties defined here:
|
| __isabstractmethod__
|
| ----------------------------------------------------------------------
| Data descriptors defined here:
|
| __dict__
| dictionary for instance variables
|
| __weakref__
| list of weak references to the object
class singledispatchmethod(builtins.object)
| singledispatchmethod(func)
|
| Single-dispatch generic method descriptor.
|
| Supports wrapping existing descriptors and handles non-descriptor
| callables as instance methods.
|
| Methods defined here:
|
| __get__(self, obj, cls=None)
|
| __init__(self, func)
| Initialize self. See help(type(self)) for accurate signature.
|
| register(self, cls, method=None)
| generic_method.register(cls, func) -> func
|
| Registers a new implementation for the given *cls* on a *generic_method*.
|
| ----------------------------------------------------------------------
| Readonly properties defined here:
|
| __isabstractmethod__
|
| ----------------------------------------------------------------------
| Data descriptors defined here:
|
| __dict__
| dictionary for instance variables
|
| __weakref__
| list of weak references to the object
FUNCTIONS
cache(user_function, /)
Simple lightweight unbounded cache. Sometimes called "memoize".
cmp_to_key(mycmp)
Convert a cmp= function into a key= function.
mycmp
Function that compares two objects.
lru_cache(maxsize=128, typed=False)
Least-recently-used cache decorator.
If *maxsize* is set to None, the LRU features are disabled and the cache
can grow without bound.
If *typed* is True, arguments of different types will be cached separately.
For example, f(3.0) and f(3) will be treated as distinct calls with
distinct results.
Arguments to the cached function must be hashable.
View the cache statistics named tuple (hits, misses, maxsize, currsize)
with f.cache_info(). Clear the cache and statistics with f.cache_clear().
Access the underlying function with f.__wrapped__.
See: https://en.wikipedia.org/wiki/Cache_replacement_policies#Least_recently_used_(LRU)
reduce(...)
reduce(function, iterable[, initial]) -> value
Apply a function of two arguments cumulatively to the items of a sequence
or iterable, from left to right, so as to reduce the iterable to a single
value. For example, reduce(lambda x, y: x+y, [1, 2, 3, 4, 5]) calculates
((((1+2)+3)+4)+5). If initial is present, it is placed before the items
of the iterable in the calculation, and serves as a default when the
iterable is empty.
singledispatch(func)
Single-dispatch generic function decorator.
Transforms a function into a generic function, which can have different
behaviours depending upon the type of its first argument. The decorated
function acts as the default implementation, and additional
implementations can be registered using the register() attribute of the
generic function.
total_ordering(cls)
Class decorator that fills in missing ordering methods
update_wrapper(wrapper, wrapped, assigned=('__module__', '__name__', '__qualname__', '__doc__', '__annotations__', '__type_params__'), updated=('__dict__',))
Update a wrapper function to look like the wrapped function
wrapper is the function to be updated
wrapped is the original function
assigned is a tuple naming the attributes assigned directly
from the wrapped function to the wrapper function (defaults to
functools.WRAPPER_ASSIGNMENTS)
updated is a tuple naming the attributes of the wrapper that
are updated with the corresponding attribute from the wrapped
function (defaults to functools.WRAPPER_UPDATES)
wraps(wrapped, assigned=('__module__', '__name__', '__qualname__', '__doc__', '__annotations__', '__type_params__'), updated=('__dict__',))
Decorator factory to apply update_wrapper() to a wrapper function
Returns a decorator that invokes update_wrapper() with the decorated
function as the wrapper argument and the arguments to wraps() as the
remaining arguments. Default arguments are as for update_wrapper().
This is a convenience function to simplify applying partial() to
update_wrapper().
DATA
WRAPPER_ASSIGNMENTS = ('__module__', '__name__', '__qualname__', '__do...
WRAPPER_UPDATES = ('__dict__',)
__all__ = ['update_wrapper', 'wraps', 'WRAPPER_ASSIGNMENTS', 'WRAPPER_...
FILE
c:\users\youse\appdata\local\programs\python\python312\lib\functools.py
fractions.math
Python Library Documentation: built-in module math
NAME
math
DESCRIPTION
This module provides access to the mathematical functions
defined by the C standard.
FUNCTIONS
acos(x, /)
Return the arc cosine (measured in radians) of x.
The result is between 0 and pi.
acosh(x, /)
Return the inverse hyperbolic cosine of x.
asin(x, /)
Return the arc sine (measured in radians) of x.
The result is between -pi/2 and pi/2.
asinh(x, /)
Return the inverse hyperbolic sine of x.
atan(x, /)
Return the arc tangent (measured in radians) of x.
The result is between -pi/2 and pi/2.
atan2(y, x, /)
Return the arc tangent (measured in radians) of y/x.
Unlike atan(y/x), the signs of both x and y are considered.
atanh(x, /)
Return the inverse hyperbolic tangent of x.
cbrt(x, /)
Return the cube root of x.
ceil(x, /)
Return the ceiling of x as an Integral.
This is the smallest integer >= x.
comb(n, k, /)
Number of ways to choose k items from n items without repetition and without order.
Evaluates to n! / (k! * (n - k)!) when k <= n and evaluates
to zero when k > n.
Also called the binomial coefficient because it is equivalent
to the coefficient of k-th term in polynomial expansion of the
expression (1 + x)**n.
Raises TypeError if either of the arguments are not integers.
Raises ValueError if either of the arguments are negative.
copysign(x, y, /)
Return a float with the magnitude (absolute value) of x but the sign of y.
On platforms that support signed zeros, copysign(1.0, -0.0)
returns -1.0.
cos(x, /)
Return the cosine of x (measured in radians).
cosh(x, /)
Return the hyperbolic cosine of x.
degrees(x, /)
Convert angle x from radians to degrees.
dist(p, q, /)
Return the Euclidean distance between two points p and q.
The points should be specified as sequences (or iterables) of
coordinates. Both inputs must have the same dimension.
Roughly equivalent to:
sqrt(sum((px - qx) ** 2.0 for px, qx in zip(p, q)))
erf(x, /)
Error function at x.
erfc(x, /)
Complementary error function at x.
exp(x, /)
Return e raised to the power of x.
exp2(x, /)
Return 2 raised to the power of x.
expm1(x, /)
Return exp(x)-1.
This function avoids the loss of precision involved in the direct evaluation of exp(x)-1 for small x.
fabs(x, /)
Return the absolute value of the float x.
factorial(n, /)
Find n!.
Raise a ValueError if x is negative or non-integral.
floor(x, /)
Return the floor of x as an Integral.
This is the largest integer <= x.
fmod(x, y, /)
Return fmod(x, y), according to platform C.
x % y may differ.
frexp(x, /)
Return the mantissa and exponent of x, as pair (m, e).
m is a float and e is an int, such that x = m * 2.**e.
If x is 0, m and e are both 0. Else 0.5 <= abs(m) < 1.0.
fsum(seq, /)
Return an accurate floating-point sum of values in the iterable seq.
Assumes IEEE-754 floating-point arithmetic.
gamma(x, /)
Gamma function at x.
gcd(*integers)
Greatest Common Divisor.
hypot(...)
hypot(*coordinates) -> value
Multidimensional Euclidean distance from the origin to a point.
Roughly equivalent to:
sqrt(sum(x**2 for x in coordinates))
For a two dimensional point (x, y), gives the hypotenuse
using the Pythagorean theorem: sqrt(x*x + y*y).
For example, the hypotenuse of a 3/4/5 right triangle is:
>>> hypot(3.0, 4.0)
5.0
isclose(a, b, *, rel_tol=1e-09, abs_tol=0.0)
Determine whether two floating-point numbers are close in value.
rel_tol
maximum difference for being considered "close", relative to the
magnitude of the input values
abs_tol
maximum difference for being considered "close", regardless of the
magnitude of the input values
Return True if a is close in value to b, and False otherwise.
For the values to be considered close, the difference between them
must be smaller than at least one of the tolerances.
-inf, inf and NaN behave similarly to the IEEE 754 Standard. That
is, NaN is not close to anything, even itself. inf and -inf are
only close to themselves.
isfinite(x, /)
Return True if x is neither an infinity nor a NaN, and False otherwise.
isinf(x, /)
Return True if x is a positive or negative infinity, and False otherwise.
isnan(x, /)
Return True if x is a NaN (not a number), and False otherwise.
isqrt(n, /)
Return the integer part of the square root of the input.
lcm(*integers)
Least Common Multiple.
ldexp(x, i, /)
Return x * (2**i).
This is essentially the inverse of frexp().
lgamma(x, /)
Natural logarithm of absolute value of Gamma function at x.
log(...)
log(x, [base=math.e])
Return the logarithm of x to the given base.
If the base is not specified, returns the natural logarithm (base e) of x.
log10(x, /)
Return the base 10 logarithm of x.
log1p(x, /)
Return the natural logarithm of 1+x (base e).
The result is computed in a way which is accurate for x near zero.
log2(x, /)
Return the base 2 logarithm of x.
modf(x, /)
Return the fractional and integer parts of x.
Both results carry the sign of x and are floats.
nextafter(x, y, /, *, steps=None)
Return the floating-point value the given number of steps after x towards y.
If steps is not specified or is None, it defaults to 1.
Raises a TypeError, if x or y is not a double, or if steps is not an integer.
Raises ValueError if steps is negative.
perm(n, k=None, /)
Number of ways to choose k items from n items without repetition and with order.
Evaluates to n! / (n - k)! when k <= n and evaluates
to zero when k > n.
If k is not specified or is None, then k defaults to n
and the function returns n!.
Raises TypeError if either of the arguments are not integers.
Raises ValueError if either of the arguments are negative.
pow(x, y, /)
Return x**y (x to the power of y).
prod(iterable, /, *, start=1)
Calculate the product of all the elements in the input iterable.
The default start value for the product is 1.
When the iterable is empty, return the start value. This function is
intended specifically for use with numeric values and may reject
non-numeric types.
radians(x, /)
Convert angle x from degrees to radians.
remainder(x, y, /)
Difference between x and the closest integer multiple of y.
Return x - n*y where n*y is the closest integer multiple of y.
In the case where x is exactly halfway between two multiples of
y, the nearest even value of n is used. The result is always exact.
sin(x, /)
Return the sine of x (measured in radians).
sinh(x, /)
Return the hyperbolic sine of x.
sqrt(x, /)
Return the square root of x.
sumprod(p, q, /)
Return the sum of products of values from two iterables p and q.
Roughly equivalent to:
sum(itertools.starmap(operator.mul, zip(p, q, strict=True)))
For float and mixed int/float inputs, the intermediate products
and sums are computed with extended precision.
tan(x, /)
Return the tangent of x (measured in radians).
tanh(x, /)
Return the hyperbolic tangent of x.
trunc(x, /)
Truncates the Real x to the nearest Integral toward 0.
Uses the __trunc__ magic method.
ulp(x, /)
Return the value of the least significant bit of the float x.
DATA
e = 2.718281828459045
inf = inf
nan = nan
pi = 3.141592653589793
tau = 6.283185307179586
FILE
(built-in)
fractions.numbers
Python Library Documentation: module numbers
NAME
numbers - Abstract Base Classes (ABCs) for numbers, according to PEP 3141.
MODULE REFERENCE
https://docs.python.org/3.12/library/numbers.html
The following documentation is automatically generated from the Python
source files. It may be incomplete, incorrect or include features that
are considered implementation detail and may vary between Python
implementations. When in doubt, consult the module reference at the
location listed above.
DESCRIPTION
TODO: Fill out more detailed documentation on the operators.
CLASSES
builtins.object
Number
Complex
Real
Rational
Integral
class Complex(Number)
| Complex defines the operations that work on the builtin complex type.
|
| In short, those are: a conversion to complex, .real, .imag, +, -,
| *, /, **, abs(), .conjugate, ==, and !=.
|
| If it is given heterogeneous arguments, and doesn't have special
| knowledge about them, it should fall back to the builtin complex
| type as described below.
|
| Method resolution order:
| Complex
| Number
| builtins.object
|
| Methods defined here:
|
| __abs__(self)
| Returns the Real distance from 0. Called for abs(self).
|
| __add__(self, other)
| self + other
|
| __bool__(self)
| True if self != 0. Called for bool(self).
|
| __complex__(self)
| Return a builtin complex instance. Called for complex(self).
|
| __eq__(self, other)
| self == other
|
| __mul__(self, other)
| self * other
|
| __neg__(self)
| -self
|
| __pos__(self)
| +self
|
| __pow__(self, exponent)
| self ** exponent; should promote to float or complex when necessary.
|
| __radd__(self, other)
| other + self
|
| __rmul__(self, other)
| other * self
|
| __rpow__(self, base)
| base ** self
|
| __rsub__(self, other)
| other - self
|
| __rtruediv__(self, other)
| other / self
|
| __sub__(self, other)
| self - other
|
| __truediv__(self, other)
| self / other: Should promote to float when necessary.
|
| conjugate(self)
| (x+y*i).conjugate() returns (x-y*i).
|
| ----------------------------------------------------------------------
| Readonly properties defined here:
|
| imag
| Retrieve the imaginary component of this number.
|
| This should subclass Real.
|
| real
| Retrieve the real component of this number.
|
| This should subclass Real.
|
| ----------------------------------------------------------------------
| Data and other attributes defined here:
|
| __abstractmethods__ = frozenset({'__abs__', '__add__', '__complex__', ...
|
| __hash__ = None
class Integral(Rational)
| Integral adds methods that work on integral numbers.
|
| In short, these are conversion to int, pow with modulus, and the
| bit-string operations.
|
| Method resolution order:
| Integral
| Rational
| Real
| Complex
| Number
| builtins.object
|
| Methods defined here:
|
| __and__(self, other)
| self & other
|
| __float__(self)
| float(self) == float(int(self))
|
| __index__(self)
| Called whenever an index is needed, such as in slicing
|
| __int__(self)
| int(self)
|
| __invert__(self)
| ~self
|
| __lshift__(self, other)
| self << other
|
| __or__(self, other)
| self | other
|
| __pow__(self, exponent, modulus=None)
| self ** exponent % modulus, but maybe faster.
|
| Accept the modulus argument if you want to support the
| 3-argument version of pow(). Raise a TypeError if exponent < 0
| or any argument isn't Integral. Otherwise, just implement the
| 2-argument version described in Complex.
|
| __rand__(self, other)
| other & self
|
| __rlshift__(self, other)
| other << self
|
| __ror__(self, other)
| other | self
|
| __rrshift__(self, other)
| other >> self
|
| __rshift__(self, other)
| self >> other
|
| __rxor__(self, other)
| other ^ self
|
| __xor__(self, other)
| self ^ other
|
| ----------------------------------------------------------------------
| Readonly properties defined here:
|
| denominator
| Integers have a denominator of 1.
|
| numerator
| Integers are their own numerators.
|
| ----------------------------------------------------------------------
| Data and other attributes defined here:
|
| __abstractmethods__ = frozenset({'__abs__', '__add__', '__and__', '__c...
|
| ----------------------------------------------------------------------
| Methods inherited from Real:
|
| __ceil__(self)
| Finds the least Integral >= self.
|
| __complex__(self)
| complex(self) == complex(float(self), 0)
|
| __divmod__(self, other)
| divmod(self, other): The pair (self // other, self % other).
|
| Sometimes this can be computed faster than the pair of
| operations.
|
| __floor__(self)
| Finds the greatest Integral <= self.
|
| __floordiv__(self, other)
| self // other: The floor() of self/other.
|
| __le__(self, other)
| self <= other
|
| __lt__(self, other)
| self < other
|
| < on Reals defines a total ordering, except perhaps for NaN.
|
| __mod__(self, other)
| self % other
|
| __rdivmod__(self, other)
| divmod(other, self): The pair (other // self, other % self).
|
| Sometimes this can be computed faster than the pair of
| operations.
|
| __rfloordiv__(self, other)
| other // self: The floor() of other/self.
|
| __rmod__(self, other)
| other % self
|
| __round__(self, ndigits=None)
| Rounds self to ndigits decimal places, defaulting to 0.
|
| If ndigits is omitted or None, returns an Integral, otherwise
| returns a Real. Rounds half toward even.
|
| __trunc__(self)
| trunc(self): Truncates self to an Integral.
|
| Returns an Integral i such that:
| * i > 0 iff self > 0;
| * abs(i) <= abs(self);
| * for any Integral j satisfying the first two conditions,
| abs(i) >= abs(j) [i.e. i has "maximal" abs among those].
| i.e. "truncate towards 0".
|
| conjugate(self)
| Conjugate is a no-op for Reals.
|
| ----------------------------------------------------------------------
| Readonly properties inherited from Real:
|
| imag
| Real numbers have no imaginary component.
|
| real
| Real numbers are their real component.
|
| ----------------------------------------------------------------------
| Methods inherited from Complex:
|
| __abs__(self)
| Returns the Real distance from 0. Called for abs(self).
|
| __add__(self, other)
| self + other
|
| __bool__(self)
| True if self != 0. Called for bool(self).
|
| __eq__(self, other)
| self == other
|
| __mul__(self, other)
| self * other
|
| __neg__(self)
| -self
|
| __pos__(self)
| +self
|
| __radd__(self, other)
| other + self
|
| __rmul__(self, other)
| other * self
|
| __rpow__(self, base)
| base ** self
|
| __rsub__(self, other)
| other - self
|
| __rtruediv__(self, other)
| other / self
|
| __sub__(self, other)
| self - other
|
| __truediv__(self, other)
| self / other: Should promote to float when necessary.
|
| ----------------------------------------------------------------------
| Data and other attributes inherited from Complex:
|
| __hash__ = None
class Number(builtins.object)
| All numbers inherit from this class.
|
| If you just want to check if an argument x is a number, without
| caring what kind, use isinstance(x, Number).
|
| Data and other attributes defined here:
|
| __abstractmethods__ = frozenset()
|
| __hash__ = None
class Rational(Real)
| .numerator and .denominator should be in lowest terms.
|
| Method resolution order:
| Rational
| Real
| Complex
| Number
| builtins.object
|
| Methods defined here:
|
| __float__(self)
| float(self) = self.numerator / self.denominator
|
| It's important that this conversion use the integer's "true"
| division rather than casting one side to float before dividing
| so that ratios of huge integers convert without overflowing.
|
| ----------------------------------------------------------------------
| Readonly properties defined here:
|
| denominator
|
| numerator
|
| ----------------------------------------------------------------------
| Data and other attributes defined here:
|
| __abstractmethods__ = frozenset({'__abs__', '__add__', '__ceil__', '__...
|
| ----------------------------------------------------------------------
| Methods inherited from Real:
|
| __ceil__(self)
| Finds the least Integral >= self.
|
| __complex__(self)
| complex(self) == complex(float(self), 0)
|
| __divmod__(self, other)
| divmod(self, other): The pair (self // other, self % other).
|
| Sometimes this can be computed faster than the pair of
| operations.
|
| __floor__(self)
| Finds the greatest Integral <= self.
|
| __floordiv__(self, other)
| self // other: The floor() of self/other.
|
| __le__(self, other)
| self <= other
|
| __lt__(self, other)
| self < other
|
| < on Reals defines a total ordering, except perhaps for NaN.
|
| __mod__(self, other)
| self % other
|
| __rdivmod__(self, other)
| divmod(other, self): The pair (other // self, other % self).
|
| Sometimes this can be computed faster than the pair of
| operations.
|
| __rfloordiv__(self, other)
| other // self: The floor() of other/self.
|
| __rmod__(self, other)
| other % self
|
| __round__(self, ndigits=None)
| Rounds self to ndigits decimal places, defaulting to 0.
|
| If ndigits is omitted or None, returns an Integral, otherwise
| returns a Real. Rounds half toward even.
|
| __trunc__(self)
| trunc(self): Truncates self to an Integral.
|
| Returns an Integral i such that:
| * i > 0 iff self > 0;
| * abs(i) <= abs(self);
| * for any Integral j satisfying the first two conditions,
| abs(i) >= abs(j) [i.e. i has "maximal" abs among those].
| i.e. "truncate towards 0".
|
| conjugate(self)
| Conjugate is a no-op for Reals.
|
| ----------------------------------------------------------------------
| Readonly properties inherited from Real:
|
| imag
| Real numbers have no imaginary component.
|
| real
| Real numbers are their real component.
|
| ----------------------------------------------------------------------
| Methods inherited from Complex:
|
| __abs__(self)
| Returns the Real distance from 0. Called for abs(self).
|
| __add__(self, other)
| self + other
|
| __bool__(self)
| True if self != 0. Called for bool(self).
|
| __eq__(self, other)
| self == other
|
| __mul__(self, other)
| self * other
|
| __neg__(self)
| -self
|
| __pos__(self)
| +self
|
| __pow__(self, exponent)
| self ** exponent; should promote to float or complex when necessary.
|
| __radd__(self, other)
| other + self
|
| __rmul__(self, other)
| other * self
|
| __rpow__(self, base)
| base ** self
|
| __rsub__(self, other)
| other - self
|
| __rtruediv__(self, other)
| other / self
|
| __sub__(self, other)
| self - other
|
| __truediv__(self, other)
| self / other: Should promote to float when necessary.
|
| ----------------------------------------------------------------------
| Data and other attributes inherited from Complex:
|
| __hash__ = None
class Real(Complex)
| To Complex, Real adds the operations that work on real numbers.
|
| In short, those are: a conversion to float, trunc(), divmod,
| %, <, <=, >, and >=.
|
| Real also provides defaults for the derived operations.
|
| Method resolution order:
| Real
| Complex
| Number
| builtins.object
|
| Methods defined here:
|
| __ceil__(self)
| Finds the least Integral >= self.
|
| __complex__(self)
| complex(self) == complex(float(self), 0)
|
| __divmod__(self, other)
| divmod(self, other): The pair (self // other, self % other).
|
| Sometimes this can be computed faster than the pair of
| operations.
|
| __float__(self)
| Any Real can be converted to a native float object.
|
| Called for float(self).
|
| __floor__(self)
| Finds the greatest Integral <= self.
|
| __floordiv__(self, other)
| self // other: The floor() of self/other.
|
| __le__(self, other)
| self <= other
|
| __lt__(self, other)
| self < other
|
| < on Reals defines a total ordering, except perhaps for NaN.
|
| __mod__(self, other)
| self % other
|
| __rdivmod__(self, other)
| divmod(other, self): The pair (other // self, other % self).
|
| Sometimes this can be computed faster than the pair of
| operations.
|
| __rfloordiv__(self, other)
| other // self: The floor() of other/self.
|
| __rmod__(self, other)
| other % self
|
| __round__(self, ndigits=None)
| Rounds self to ndigits decimal places, defaulting to 0.
|
| If ndigits is omitted or None, returns an Integral, otherwise
| returns a Real. Rounds half toward even.
|
| __trunc__(self)
| trunc(self): Truncates self to an Integral.
|
| Returns an Integral i such that:
| * i > 0 iff self > 0;
| * abs(i) <= abs(self);
| * for any Integral j satisfying the first two conditions,
| abs(i) >= abs(j) [i.e. i has "maximal" abs among those].
| i.e. "truncate towards 0".
|
| conjugate(self)
| Conjugate is a no-op for Reals.
|
| ----------------------------------------------------------------------
| Readonly properties defined here:
|
| imag
| Real numbers have no imaginary component.
|
| real
| Real numbers are their real component.
|
| ----------------------------------------------------------------------
| Data and other attributes defined here:
|
| __abstractmethods__ = frozenset({'__abs__', '__add__', '__ceil__', '__...
|
| ----------------------------------------------------------------------
| Methods inherited from Complex:
|
| __abs__(self)
| Returns the Real distance from 0. Called for abs(self).
|
| __add__(self, other)
| self + other
|
| __bool__(self)
| True if self != 0. Called for bool(self).
|
| __eq__(self, other)
| self == other
|
| __mul__(self, other)
| self * other
|
| __neg__(self)
| -self
|
| __pos__(self)
| +self
|
| __pow__(self, exponent)
| self ** exponent; should promote to float or complex when necessary.
|
| __radd__(self, other)
| other + self
|
| __rmul__(self, other)
| other * self
|
| __rpow__(self, base)
| base ** self
|
| __rsub__(self, other)
| other - self
|
| __rtruediv__(self, other)
| other / self
|
| __sub__(self, other)
| self - other
|
| __truediv__(self, other)
| self / other: Should promote to float when necessary.
|
| ----------------------------------------------------------------------
| Data and other attributes inherited from Complex:
|
| __hash__ = None
DATA
__all__ = ['Number', 'Complex', 'Real', 'Rational', 'Integral']
FILE
c:\users\youse\appdata\local\programs\python\python312\lib\numbers.py
fractions.operator
Python Library Documentation: module operator
NAME
operator - Operator interface.
MODULE REFERENCE
https://docs.python.org/3.12/library/operator.html
The following documentation is automatically generated from the Python
source files. It may be incomplete, incorrect or include features that
are considered implementation detail and may vary between Python
implementations. When in doubt, consult the module reference at the
location listed above.
DESCRIPTION
This module exports a set of functions implemented in C corresponding
to the intrinsic operators of Python. For example, operator.add(x, y)
is equivalent to the expression x+y. The function names are those
used for special methods; variants without leading and trailing
'__' are also provided for convenience.
CLASSES
builtins.object
attrgetter
itemgetter
methodcaller
class attrgetter(builtins.object)
| attrgetter(attr, /, *attrs)
|
| Return a callable object that fetches the given attribute(s) from its operand.
| After f = attrgetter('name'), the call f(r) returns r.name.
| After g = attrgetter('name', 'date'), the call g(r) returns (r.name, r.date).
| After h = attrgetter('name.first', 'name.last'), the call h(r) returns
| (r.name.first, r.name.last).
|
| Methods defined here:
|
| __call__(self, /, *args, **kwargs)
| Call self as a function.
|
| __getattribute__(self, name, /)
| Return getattr(self, name).
|
| __reduce__(...)
| Return state information for pickling
|
| __repr__(self, /)
| Return repr(self).
|
| ----------------------------------------------------------------------
| Static methods defined here:
|
| __new__(*args, **kwargs)
| Create and return a new object. See help(type) for accurate signature.
|
| ----------------------------------------------------------------------
| Data descriptors defined here:
|
| __vectorcalloffset__
class itemgetter(builtins.object)
| itemgetter(item, /, *items)
|
| Return a callable object that fetches the given item(s) from its operand.
| After f = itemgetter(2), the call f(r) returns r[2].
| After g = itemgetter(2, 5, 3), the call g(r) returns (r[2], r[5], r[3])
|
| Methods defined here:
|
| __call__(self, /, *args, **kwargs)
| Call self as a function.
|
| __getattribute__(self, name, /)
| Return getattr(self, name).
|
| __reduce__(...)
| Return state information for pickling
|
| __repr__(self, /)
| Return repr(self).
|
| ----------------------------------------------------------------------
| Static methods defined here:
|
| __new__(*args, **kwargs)
| Create and return a new object. See help(type) for accurate signature.
|
| ----------------------------------------------------------------------
| Data descriptors defined here:
|
| __vectorcalloffset__
class methodcaller(builtins.object)
| methodcaller(name, /, *args, **kwargs)
|
| Return a callable object that calls the given method on its operand.
| After f = methodcaller('name'), the call f(r) returns r.name().
| After g = methodcaller('name', 'date', foo=1), the call g(r) returns
| r.name('date', foo=1).
|
| Methods defined here:
|
| __call__(self, /, *args, **kwargs)
| Call self as a function.
|
| __getattribute__(self, name, /)
| Return getattr(self, name).
|
| __reduce__(...)
| Return state information for pickling
|
| __repr__(self, /)
| Return repr(self).
|
| ----------------------------------------------------------------------
| Static methods defined here:
|
| __new__(*args, **kwargs)
| Create and return a new object. See help(type) for accurate signature.
FUNCTIONS
__abs__ = abs(a, /)
Same as abs(a).
__add__ = add(a, b, /)
Same as a + b.
__and__ = and_(a, b, /)
Same as a & b.
__call__ = call(obj, /, *args, **kwargs)
Same as obj(*args, **kwargs).
__concat__ = concat(a, b, /)
Same as a + b, for a and b sequences.
__contains__ = contains(a, b, /)
Same as b in a (note reversed operands).
__delitem__ = delitem(a, b, /)
Same as del a[b].
__eq__ = eq(a, b, /)
Same as a == b.
__floordiv__ = floordiv(a, b, /)
Same as a // b.
__ge__ = ge(a, b, /)
Same as a >= b.
__getitem__ = getitem(a, b, /)
Same as a[b].
__gt__ = gt(a, b, /)
Same as a > b.
__iadd__ = iadd(a, b, /)
Same as a += b.
__iand__ = iand(a, b, /)
Same as a &= b.
__iconcat__ = iconcat(a, b, /)
Same as a += b, for a and b sequences.
__ifloordiv__ = ifloordiv(a, b, /)
Same as a //= b.
__ilshift__ = ilshift(a, b, /)
Same as a <<= b.
__imatmul__ = imatmul(a, b, /)
Same as a @= b.
__imod__ = imod(a, b, /)
Same as a %= b.
__imul__ = imul(a, b, /)
Same as a *= b.
__index__ = index(a, /)
Same as a.__index__()
__inv__ = inv(a, /)
Same as ~a.
__invert__ = invert(a, /)
Same as ~a.
__ior__ = ior(a, b, /)
Same as a |= b.
__ipow__ = ipow(a, b, /)
Same as a **= b.
__irshift__ = irshift(a, b, /)
Same as a >>= b.
__isub__ = isub(a, b, /)
Same as a -= b.
__itruediv__ = itruediv(a, b, /)
Same as a /= b.
__ixor__ = ixor(a, b, /)
Same as a ^= b.
__le__ = le(a, b, /)
Same as a <= b.
__lshift__ = lshift(a, b, /)
Same as a << b.
__lt__ = lt(a, b, /)
Same as a < b.
__matmul__ = matmul(a, b, /)
Same as a @ b.
__mod__ = mod(a, b, /)
Same as a % b.
__mul__ = mul(a, b, /)
Same as a * b.
__ne__ = ne(a, b, /)
Same as a != b.
__neg__ = neg(a, /)
Same as -a.
__not__ = not_(a, /)
Same as not a.
__or__ = or_(a, b, /)
Same as a | b.
__pos__ = pos(a, /)
Same as +a.
__pow__ = pow(a, b, /)
Same as a ** b.
__rshift__ = rshift(a, b, /)
Same as a >> b.
__setitem__ = setitem(a, b, c, /)
Same as a[b] = c.
__sub__ = sub(a, b, /)
Same as a - b.
__truediv__ = truediv(a, b, /)
Same as a / b.
__xor__ = xor(a, b, /)
Same as a ^ b.
abs(a, /)
Same as abs(a).
add(a, b, /)
Same as a + b.
and_(a, b, /)
Same as a & b.
call(obj, /, *args, **kwargs)
Same as obj(*args, **kwargs).
concat(a, b, /)
Same as a + b, for a and b sequences.
contains(a, b, /)
Same as b in a (note reversed operands).
countOf(a, b, /)
Return the number of items in a which are, or which equal, b.
delitem(a, b, /)
Same as del a[b].
eq(a, b, /)
Same as a == b.
floordiv(a, b, /)
Same as a // b.
ge(a, b, /)
Same as a >= b.
getitem(a, b, /)
Same as a[b].
gt(a, b, /)
Same as a > b.
iadd(a, b, /)
Same as a += b.
iand(a, b, /)
Same as a &= b.
iconcat(a, b, /)
Same as a += b, for a and b sequences.
ifloordiv(a, b, /)
Same as a //= b.
ilshift(a, b, /)
Same as a <<= b.
imatmul(a, b, /)
Same as a @= b.
imod(a, b, /)
Same as a %= b.
imul(a, b, /)
Same as a *= b.
index(a, /)
Same as a.__index__()
indexOf(a, b, /)
Return the first index of b in a.
inv(a, /)
Same as ~a.
invert(a, /)
Same as ~a.
ior(a, b, /)
Same as a |= b.
ipow(a, b, /)
Same as a **= b.
irshift(a, b, /)
Same as a >>= b.
is_(a, b, /)
Same as a is b.
is_not(a, b, /)
Same as a is not b.
isub(a, b, /)
Same as a -= b.
itruediv(a, b, /)
Same as a /= b.
ixor(a, b, /)
Same as a ^= b.
le(a, b, /)
Same as a <= b.
length_hint(obj, default=0, /)
Return an estimate of the number of items in obj.
This is useful for presizing containers when building from an iterable.
If the object supports len(), the result will be exact.
Otherwise, it may over- or under-estimate by an arbitrary amount.
The result will be an integer >= 0.
lshift(a, b, /)
Same as a << b.
lt(a, b, /)
Same as a < b.
matmul(a, b, /)
Same as a @ b.
mod(a, b, /)
Same as a % b.
mul(a, b, /)
Same as a * b.
ne(a, b, /)
Same as a != b.
neg(a, /)
Same as -a.
not_(a, /)
Same as not a.
or_(a, b, /)
Same as a | b.
pos(a, /)
Same as +a.
pow(a, b, /)
Same as a ** b.
rshift(a, b, /)
Same as a >> b.
setitem(a, b, c, /)
Same as a[b] = c.
sub(a, b, /)
Same as a - b.
truediv(a, b, /)
Same as a / b.
truth(a, /)
Return True if a is true, False otherwise.
xor(a, b, /)
Same as a ^ b.
DATA
__all__ = ['abs', 'add', 'and_', 'attrgetter', 'call', 'concat', 'cont...
FILE
c:\users\youse\appdata\local\programs\python\python312\lib\operator.py
fractions.re
Python Library Documentation: package re
NAME
re - Support for regular expressions (RE).
MODULE REFERENCE
https://docs.python.org/3.12/library/re.html
The following documentation is automatically generated from the Python
source files. It may be incomplete, incorrect or include features that
are considered implementation detail and may vary between Python
implementations. When in doubt, consult the module reference at the
location listed above.
DESCRIPTION
This module provides regular expression matching operations similar to
those found in Perl. It supports both 8-bit and Unicode strings; both
the pattern and the strings being processed can contain null bytes and
characters outside the US ASCII range.
Regular expressions can contain both special and ordinary characters.
Most ordinary characters, like "A", "a", or "0", are the simplest
regular expressions; they simply match themselves. You can
concatenate ordinary characters, so last matches the string 'last'.
The special characters are:
"." Matches any character except a newline.
"^" Matches the start of the string.
"$" Matches the end of the string or just before the newline at
the end of the string.
"*" Matches 0 or more (greedy) repetitions of the preceding RE.
Greedy means that it will match as many repetitions as possible.
"+" Matches 1 or more (greedy) repetitions of the preceding RE.
"?" Matches 0 or 1 (greedy) of the preceding RE.
*?,+?,?? Non-greedy versions of the previous three special characters.
{m,n} Matches from m to n repetitions of the preceding RE.
{m,n}? Non-greedy version of the above.
"\\" Either escapes special characters or signals a special sequence.
[] Indicates a set of characters.
A "^" as the first character indicates a complementing set.
"|" A|B, creates an RE that will match either A or B.
(...) Matches the RE inside the parentheses.
The contents can be retrieved or matched later in the string.
(?aiLmsux) The letters set the corresponding flags defined below.
(?:...) Non-grouping version of regular parentheses.
(?P<name>...) The substring matched by the group is accessible by name.
(?P=name) Matches the text matched earlier by the group named name.
(?#...) A comment; ignored.
(?=...) Matches if ... matches next, but doesn't consume the string.
(?!...) Matches if ... doesn't match next.
(?<=...) Matches if preceded by ... (must be fixed length).
(?<!...) Matches if not preceded by ... (must be fixed length).
(?(id/name)yes|no) Matches yes pattern if the group with id/name matched,
the (optional) no pattern otherwise.
The special sequences consist of "\\" and a character from the list
below. If the ordinary character is not on the list, then the
resulting RE will match the second character.
\number Matches the contents of the group of the same number.
\A Matches only at the start of the string.
\Z Matches only at the end of the string.
\b Matches the empty string, but only at the start or end of a word.
\B Matches the empty string, but not at the start or end of a word.
\d Matches any decimal digit; equivalent to the set [0-9] in
bytes patterns or string patterns with the ASCII flag.
In string patterns without the ASCII flag, it will match the whole
range of Unicode digits.
\D Matches any non-digit character; equivalent to [^\d].
\s Matches any whitespace character; equivalent to [ \t\n\r\f\v] in
bytes patterns or string patterns with the ASCII flag.
In string patterns without the ASCII flag, it will match the whole
range of Unicode whitespace characters.
\S Matches any non-whitespace character; equivalent to [^\s].
\w Matches any alphanumeric character; equivalent to [a-zA-Z0-9_]
in bytes patterns or string patterns with the ASCII flag.
In string patterns without the ASCII flag, it will match the
range of Unicode alphanumeric characters (letters plus digits
plus underscore).
With LOCALE, it will match the set [0-9_] plus characters defined
as letters for the current locale.
\W Matches the complement of \w.
\\ Matches a literal backslash.
This module exports the following functions:
match Match a regular expression pattern to the beginning of a string.
fullmatch Match a regular expression pattern to all of a string.
search Search a string for the presence of a pattern.
sub Substitute occurrences of a pattern found in a string.
subn Same as sub, but also return the number of substitutions made.
split Split a string by the occurrences of a pattern.
findall Find all occurrences of a pattern in a string.
finditer Return an iterator yielding a Match object for each match.
compile Compile a pattern into a Pattern object.
purge Clear the regular expression cache.
escape Backslash all non-alphanumerics in a string.
Each function other than purge and escape can take an optional 'flags' argument
consisting of one or more of the following module constants, joined by "|".
A, L, and U are mutually exclusive.
A ASCII For string patterns, make \w, \W, \b, \B, \d, \D
match the corresponding ASCII character categories
(rather than the whole Unicode categories, which is the
default).
For bytes patterns, this flag is the only available
behaviour and needn't be specified.
I IGNORECASE Perform case-insensitive matching.
L LOCALE Make \w, \W, \b, \B, dependent on the current locale.
M MULTILINE "^" matches the beginning of lines (after a newline)
as well as the string.
"$" matches the end of lines (before a newline) as well
as the end of the string.
S DOTALL "." matches any character at all, including the newline.
X VERBOSE Ignore whitespace and comments for nicer looking RE's.
U UNICODE For compatibility only. Ignored for string patterns (it
is the default), and forbidden for bytes patterns.
This module also defines an exception 'error'.
PACKAGE CONTENTS
_casefix
_compiler
_constants
_parser
CLASSES
builtins.Exception(builtins.BaseException)
error
builtins.object
Match
Pattern
enum.IntFlag(builtins.int, enum.ReprEnum, enum.Flag)
RegexFlag
class Match(builtins.object)
| The result of re.match() and re.search().
| Match objects always have a boolean value of True.
|
| Methods defined here:
|
| __copy__(self, /)
|
| __deepcopy__(self, memo, /)
|
| __getitem__(self, key, /)
| Return self[key].
|
| __repr__(self, /)
| Return repr(self).
|
| end(self, group=0, /)
| Return index of the end of the substring matched by group.
|
| expand(self, /, template)
| Return the string obtained by doing backslash substitution on the string template, as done by the sub() method.
|
| group(...)
| group([group1, ...]) -> str or tuple.
| Return subgroup(s) of the match by indices or names.
| For 0 returns the entire match.
|
| groupdict(self, /, default=None)
| Return a dictionary containing all the named subgroups of the match, keyed by the subgroup name.
|
| default
| Is used for groups that did not participate in the match.
|
| groups(self, /, default=None)
| Return a tuple containing all the subgroups of the match, from 1.
|
| default
| Is used for groups that did not participate in the match.
|
| span(self, group=0, /)
| For match object m, return the 2-tuple (m.start(group), m.end(group)).
|
| start(self, group=0, /)
| Return index of the start of the substring matched by group.
|
| ----------------------------------------------------------------------
| Class methods defined here:
|
| __class_getitem__(...)
| See PEP 585
|
| ----------------------------------------------------------------------
| Data descriptors defined here:
|
| endpos
| The index into the string beyond which the RE engine will not go.
|
| lastgroup
| The name of the last matched capturing group.
|
| lastindex
| The integer index of the last matched capturing group.
|
| pos
| The index into the string at which the RE engine started looking for a match.
|
| re
| The regular expression object.
|
| regs
|
| string
| The string passed to match() or search().
class Pattern(builtins.object)
| Compiled regular expression object.
|
| Methods defined here:
|
| __copy__(self, /)
|
| __deepcopy__(self, memo, /)
|
| __eq__(self, value, /)
| Return self==value.
|
| __ge__(self, value, /)
| Return self>=value.
|
| __gt__(self, value, /)
| Return self>value.
|
| __hash__(self, /)
| Return hash(self).
|
| __le__(self, value, /)
| Return self<=value.
|
| __lt__(self, value, /)
| Return self<value.
|
| __ne__(self, value, /)
| Return self!=value.
|
| __repr__(self, /)
| Return repr(self).
|
| findall(self, /, string, pos=0, endpos=9223372036854775807)
| Return a list of all non-overlapping matches of pattern in string.
|
| finditer(self, /, string, pos=0, endpos=9223372036854775807)
| Return an iterator over all non-overlapping matches for the RE pattern in string.
|
| For each match, the iterator returns a match object.
|
| fullmatch(self, /, string, pos=0, endpos=9223372036854775807)
| Matches against all of the string.
|
| match(self, /, string, pos=0, endpos=9223372036854775807)
| Matches zero or more characters at the beginning of the string.
|
| scanner(self, /, string, pos=0, endpos=9223372036854775807)
|
| search(self, /, string, pos=0, endpos=9223372036854775807)
| Scan through string looking for a match, and return a corresponding match object instance.
|
| Return None if no position in the string matches.
|
| split(self, /, string, maxsplit=0)
| Split string by the occurrences of pattern.
|
| sub(self, /, repl, string, count=0)
| Return the string obtained by replacing the leftmost non-overlapping occurrences of pattern in string by the replacement repl.
|
| subn(self, /, repl, string, count=0)
| Return the tuple (new_string, number_of_subs_made) found by replacing the leftmost non-overlapping occurrences of pattern with the replacement repl.
|
| ----------------------------------------------------------------------
| Class methods defined here:
|
| __class_getitem__(...)
| See PEP 585
|
| ----------------------------------------------------------------------
| Data descriptors defined here:
|
| flags
| The regex matching flags.
|
| groupindex
| A dictionary mapping group names to group numbers.
|
| groups
| The number of capturing groups in the pattern.
|
| pattern
| The pattern string from which the RE object was compiled.
class RegexFlag(enum.IntFlag)
| RegexFlag(*values)
|
| An enumeration.
|
| Method resolution order:
| RegexFlag
| enum.IntFlag
| builtins.int
| enum.ReprEnum
| enum.Flag
| enum.Enum
| builtins.object
|
| Methods defined here:
|
| __and__(self, other) from enum.Flag
|
| __format__(self, format_spec, /) from builtins.int
| Convert to a string according to format_spec.
|
| __invert__(self) from enum.Flag
|
| __new__(cls, value) from enum.Enum
| Create and return a new object. See help(type) for accurate signature.
|
| __or__(self, other) from enum.Flag
| Return self|value.
|
| __rand__ = __and__(self, other)
|
| __repr__ = global_flag_repr(self) from enum
| use module.flag_name instead of class.flag_name
|
| the module is the last module in case of a multi-module name
|
| __ror__ = __or__(self, other)
|
| __rxor__ = __xor__(self, other)
|
| __str__(self, /) from builtins.object
| Return str(self).
|
| __xor__(self, other) from enum.Flag
|
| ----------------------------------------------------------------------
| Data and other attributes defined here:
|
| ASCII = re.ASCII
|
| DEBUG = re.DEBUG
|
| DOTALL = re.DOTALL
|
| IGNORECASE = re.IGNORECASE
|
| LOCALE = re.LOCALE
|
| MULTILINE = re.MULTILINE
|
| TEMPLATE = re.TEMPLATE
|
| UNICODE = re.UNICODE
|
| VERBOSE = re.VERBOSE
|
| ----------------------------------------------------------------------
| Methods inherited from builtins.int:
|
| __abs__(self, /)
| abs(self)
|
| __add__(self, value, /)
| Return self+value.
|
| __bool__(self, /)
| True if self else False
|
| __ceil__(...)
| Ceiling of an Integral returns itself.
|
| __divmod__(self, value, /)
| Return divmod(self, value).
|
| __eq__(self, value, /)
| Return self==value.
|
| __float__(self, /)
| float(self)
|
| __floor__(...)
| Flooring an Integral returns itself.
|
| __floordiv__(self, value, /)
| Return self//value.
|
| __ge__(self, value, /)
| Return self>=value.
|
| __getattribute__(self, name, /)
| Return getattr(self, name).
|
| __getnewargs__(self, /)
|
| __gt__(self, value, /)
| Return self>value.
|
| __hash__(self, /)
| Return hash(self).
|
| __index__(self, /)
| Return self converted to an integer, if self is suitable for use as an index into a list.
|
| __int__(self, /)
| int(self)
|
| __le__(self, value, /)
| Return self<=value.
|
| __lshift__(self, value, /)
| Return self<<value.
|
| __lt__(self, value, /)
| Return self<value.
|
| __mod__(self, value, /)
| Return self%value.
|
| __mul__(self, value, /)
| Return self*value.
|
| __ne__(self, value, /)
| Return self!=value.
|
| __neg__(self, /)
| -self
|
| __pos__(self, /)
| +self
|
| __pow__(self, value, mod=None, /)
| Return pow(self, value, mod).
|
| __radd__(self, value, /)
| Return value+self.
|
| __rdivmod__(self, value, /)
| Return divmod(value, self).
|
| __rfloordiv__(self, value, /)
| Return value//self.
|
| __rlshift__(self, value, /)
| Return value<<self.
|
| __rmod__(self, value, /)
| Return value%self.
|
| __rmul__(self, value, /)
| Return value*self.
|
| __round__(...)
| Rounding an Integral returns itself.
|
| Rounding with an ndigits argument also returns an integer.
|
| __rpow__(self, value, mod=None, /)
| Return pow(value, self, mod).
|
| __rrshift__(self, value, /)
| Return value>>self.
|
| __rshift__(self, value, /)
| Return self>>value.
|
| __rsub__(self, value, /)
| Return value-self.
|
| __rtruediv__(self, value, /)
| Return value/self.
|
| __sizeof__(self, /)
| Returns size in memory, in bytes.
|
| __sub__(self, value, /)
| Return self-value.
|
| __truediv__(self, value, /)
| Return self/value.
|
| __trunc__(...)
| Truncating an Integral returns itself.
|
| as_integer_ratio(self, /)
| Return a pair of integers, whose ratio is equal to the original int.
|
| The ratio is in lowest terms and has a positive denominator.
|
| >>> (10).as_integer_ratio()
| (10, 1)
| >>> (-10).as_integer_ratio()
| (-10, 1)
| >>> (0).as_integer_ratio()
| (0, 1)
|
| bit_count(self, /)
| Number of ones in the binary representation of the absolute value of self.
|
| Also known as the population count.
|
| >>> bin(13)
| '0b1101'
| >>> (13).bit_count()
| 3
|
| bit_length(self, /)
| Number of bits necessary to represent self in binary.
|
| >>> bin(37)
| '0b100101'
| >>> (37).bit_length()
| 6
|
| conjugate(...)
| Returns self, the complex conjugate of any int.
|
| is_integer(self, /)
| Returns True. Exists for duck type compatibility with float.is_integer.
|
| to_bytes(self, /, length=1, byteorder='big', *, signed=False)
| Return an array of bytes representing an integer.
|
| length
| Length of bytes object to use. An OverflowError is raised if the
| integer is not representable with the given number of bytes. Default
| is length 1.
| byteorder
| The byte order used to represent the integer. If byteorder is 'big',
| the most significant byte is at the beginning of the byte array. If
| byteorder is 'little', the most significant byte is at the end of the
| byte array. To request the native byte order of the host system, use
| `sys.byteorder' as the byte order value. Default is to use 'big'.
| signed
| Determines whether two's complement is used to represent the integer.
| If signed is False and a negative integer is given, an OverflowError
| is raised.
|
| ----------------------------------------------------------------------
| Class methods inherited from builtins.int:
|
| from_bytes(bytes, byteorder='big', *, signed=False)
| Return the integer represented by the given array of bytes.
|
| bytes
| Holds the array of bytes to convert. The argument must either
| support the buffer protocol or be an iterable object producing bytes.
| Bytes and bytearray are examples of built-in objects that support the
| buffer protocol.
| byteorder
| The byte order used to represent the integer. If byteorder is 'big',
| the most significant byte is at the beginning of the byte array. If
| byteorder is 'little', the most significant byte is at the end of the
| byte array. To request the native byte order of the host system, use
| `sys.byteorder' as the byte order value. Default is to use 'big'.
| signed
| Indicates whether two's complement is used to represent the integer.
|
| ----------------------------------------------------------------------
| Data descriptors inherited from builtins.int:
|
| denominator
| the denominator of a rational number in lowest terms
|
| imag
| the imaginary part of a complex number
|
| numerator
| the numerator of a rational number in lowest terms
|
| real
| the real part of a complex number
|
| ----------------------------------------------------------------------
| Methods inherited from enum.Flag:
|
| __contains__(self, other)
| Returns True if self has at least the same flags set as other.
|
| __iter__(self)
| Returns flags in definition order.
|
| __len__(self)
| Return the number of members (no aliases)
|
| ----------------------------------------------------------------------
| Methods inherited from enum.Enum:
|
| __dir__(self)
| Returns public methods and other interesting attributes.
|
| __init__(self, *args, **kwds)
| Initialize self. See help(type(self)) for accurate signature.
|
| __reduce_ex__(self, proto)
| Helper for pickle.
|
| ----------------------------------------------------------------------
| Data descriptors inherited from enum.Enum:
|
| name
| The name of the Enum member.
|
| value
| The value of the Enum member.
|
| ----------------------------------------------------------------------
| Static methods inherited from enum.EnumType:
|
| __getitem__(name)
| Return the member matching `name`.
|
| ----------------------------------------------------------------------
| Readonly properties inherited from enum.EnumType:
|
| __members__
| Returns a mapping of member name->value.
|
| This mapping lists all enum members, including aliases. Note that this
| is a read-only view of the internal mapping.
class error(builtins.Exception)
| error(msg, pattern=None, pos=None)
|
| Exception raised for invalid regular expressions.
|
| Attributes:
|
| msg: The unformatted error message
| pattern: The regular expression pattern
| pos: The index in the pattern where compilation failed (may be None)
| lineno: The line corresponding to pos (may be None)
| colno: The column corresponding to pos (may be None)
|
| Method resolution order:
| error
| builtins.Exception
| builtins.BaseException
| builtins.object
|
| Methods defined here:
|
| __init__(self, msg, pattern=None, pos=None) from re._constants.error
| Initialize self. See help(type(self)) for accurate signature.
|
| ----------------------------------------------------------------------
| Data descriptors defined here:
|
| __weakref__
| list of weak references to the object
|
| ----------------------------------------------------------------------
| Static methods inherited from builtins.Exception:
|
| __new__(*args, **kwargs) class method of builtins.Exception
| Create and return a new object. See help(type) for accurate signature.
|
| ----------------------------------------------------------------------
| Methods inherited from builtins.BaseException:
|
| __getattribute__(self, name, /)
| Return getattr(self, name).
|
| __reduce__(...)
| Helper for pickle.
|
| __repr__(self, /)
| Return repr(self).
|
| __setstate__(...)
|
| __str__(self, /)
| Return str(self).
|
| add_note(...)
| Exception.add_note(note) --
| add a note to the exception
|
| with_traceback(...)
| Exception.with_traceback(tb) --
| set self.__traceback__ to tb and return self.
|
| ----------------------------------------------------------------------
| Data descriptors inherited from builtins.BaseException:
|
| __cause__
| exception cause
|
| __context__
| exception context
|
| __dict__
|
| __suppress_context__
|
| __traceback__
|
| args
FUNCTIONS
compile(pattern, flags=0)
Compile a regular expression pattern, returning a Pattern object.
escape(pattern)
Escape special characters in a string.
findall(pattern, string, flags=0)
Return a list of all non-overlapping matches in the string.
If one or more capturing groups are present in the pattern, return
a list of groups; this will be a list of tuples if the pattern
has more than one group.
Empty matches are included in the result.
finditer(pattern, string, flags=0)
Return an iterator over all non-overlapping matches in the
string. For each match, the iterator returns a Match object.
Empty matches are included in the result.
fullmatch(pattern, string, flags=0)
Try to apply the pattern to all of the string, returning
a Match object, or None if no match was found.
match(pattern, string, flags=0)
Try to apply the pattern at the start of the string, returning
a Match object, or None if no match was found.
purge()
Clear the regular expression caches
search(pattern, string, flags=0)
Scan through string looking for a match to the pattern, returning
a Match object, or None if no match was found.
split(pattern, string, maxsplit=0, flags=0)
Split the source string by the occurrences of the pattern,
returning a list containing the resulting substrings. If
capturing parentheses are used in pattern, then the text of all
groups in the pattern are also returned as part of the resulting
list. If maxsplit is nonzero, at most maxsplit splits occur,
and the remainder of the string is returned as the final element
of the list.
sub(pattern, repl, string, count=0, flags=0)
Return the string obtained by replacing the leftmost
non-overlapping occurrences of the pattern in string by the
replacement repl. repl can be either a string or a callable;
if a string, backslash escapes in it are processed. If it is
a callable, it's passed the Match object and must return
a replacement string to be used.
subn(pattern, repl, string, count=0, flags=0)
Return a 2-tuple containing (new_string, number).
new_string is the string obtained by replacing the leftmost
non-overlapping occurrences of the pattern in the source
string by the replacement repl. number is the number of
substitutions that were made. repl can be either a string or a
callable; if a string, backslash escapes in it are processed.
If it is a callable, it's passed the Match object and must
return a replacement string to be used.
template(pattern, flags=0)
Compile a template pattern, returning a Pattern object, deprecated
DATA
A = re.ASCII
ASCII = re.ASCII
DOTALL = re.DOTALL
I = re.IGNORECASE
IGNORECASE = re.IGNORECASE
L = re.LOCALE
LOCALE = re.LOCALE
M = re.MULTILINE
MULTILINE = re.MULTILINE
NOFLAG = re.NOFLAG
S = re.DOTALL
U = re.UNICODE
UNICODE = re.UNICODE
VERBOSE = re.VERBOSE
X = re.VERBOSE
__all__ = ['match', 'fullmatch', 'search', 'sub', 'subn', 'split', 'fi...
VERSION
2.2.1
FILE
c:\users\youse\appdata\local\programs\python\python312\lib\re\__init__.py
fractions.sys
Python Library Documentation: built-in module sys
NAME
sys
MODULE REFERENCE
https://docs.python.org/3.12/library/sys.html
The following documentation is automatically generated from the Python
source files. It may be incomplete, incorrect or include features that
are considered implementation detail and may vary between Python
implementations. When in doubt, consult the module reference at the
location listed above.
DESCRIPTION
This module provides access to some objects used or maintained by the
interpreter and to functions that interact strongly with the interpreter.
Dynamic objects:
argv -- command line arguments; argv[0] is the script pathname if known
path -- module search path; path[0] is the script directory, else ''
modules -- dictionary of loaded modules
displayhook -- called to show results in an interactive session
excepthook -- called to handle any uncaught exception other than SystemExit
To customize printing in an interactive session or to install a custom
top-level exception handler, assign other functions to replace these.
stdin -- standard input file object; used by input()
stdout -- standard output file object; used by print()
stderr -- standard error object; used for error messages
By assigning other file objects (or objects that behave like files)
to these, it is possible to redirect all of the interpreter's I/O.
last_exc - the last uncaught exception
Only available in an interactive session after a
traceback has been printed.
last_type -- type of last uncaught exception
last_value -- value of last uncaught exception
last_traceback -- traceback of last uncaught exception
These three are the (deprecated) legacy representation of last_exc.
Static objects:
builtin_module_names -- tuple of module names built into this interpreter
copyright -- copyright notice pertaining to this interpreter
exec_prefix -- prefix used to find the machine-specific Python library
executable -- absolute path of the executable binary of the Python interpreter
float_info -- a named tuple with information about the float implementation.
float_repr_style -- string indicating the style of repr() output for floats
hash_info -- a named tuple with information about the hash algorithm.
hexversion -- version information encoded as a single integer
implementation -- Python implementation information.
int_info -- a named tuple with information about the int implementation.
maxsize -- the largest supported length of containers.
maxunicode -- the value of the largest Unicode code point
platform -- platform identifier
prefix -- prefix used to find the Python library
thread_info -- a named tuple with information about the thread implementation.
version -- the version of this interpreter as a string
version_info -- version information as a named tuple
dllhandle -- [Windows only] integer handle of the Python DLL
winver -- [Windows only] version number of the Python DLL
_enablelegacywindowsfsencoding -- [Windows only]
__stdin__ -- the original stdin; don't touch!
__stdout__ -- the original stdout; don't touch!
__stderr__ -- the original stderr; don't touch!
__displayhook__ -- the original displayhook; don't touch!
__excepthook__ -- the original excepthook; don't touch!
Functions:
displayhook() -- print an object to the screen, and save it in builtins._
excepthook() -- print an exception and its traceback to sys.stderr
exception() -- return the current thread's active exception
exc_info() -- return information about the current thread's active exception
exit() -- exit the interpreter by raising SystemExit
getdlopenflags() -- returns flags to be used for dlopen() calls
getprofile() -- get the global profiling function
getrefcount() -- return the reference count for an object (plus one :-)
getrecursionlimit() -- return the max recursion depth for the interpreter
getsizeof() -- return the size of an object in bytes
gettrace() -- get the global debug tracing function
setdlopenflags() -- set the flags to be used for dlopen() calls
setprofile() -- set the global profiling function
setrecursionlimit() -- set the max recursion depth for the interpreter
settrace() -- set the global debug tracing function
SUBMODULES
monitoring
FUNCTIONS
__breakpointhook__ = breakpointhook(...)
breakpointhook(*args, **kws)
This hook function is called by built-in breakpoint().
__displayhook__ = displayhook(object, /)
Print an object to sys.stdout and also save it in builtins._
__excepthook__ = excepthook(exctype, value, traceback, /)
Handle an exception by displaying it with a traceback on sys.stderr.
__unraisablehook__ = unraisablehook(unraisable, /)
Handle an unraisable exception.
The unraisable argument has the following attributes:
* exc_type: Exception type.
* exc_value: Exception value, can be None.
* exc_traceback: Exception traceback, can be None.
* err_msg: Error message, can be None.
* object: Object causing the exception, can be None.
activate_stack_trampoline(backend, /)
Activate stack profiler trampoline *backend*.
addaudithook(hook)
Adds a new audit hook callback.
audit(...)
audit(event, *args)
Passes the event to any audit hooks that are attached.
breakpointhook(...)
breakpointhook(*args, **kws)
This hook function is called by built-in breakpoint().
call_tracing(func, args, /)
Call func(*args), while tracing is enabled.
The tracing state is saved, and restored afterwards. This is intended
to be called from a debugger from a checkpoint, to recursively debug
some other code.
deactivate_stack_trampoline()
Deactivate the current stack profiler trampoline backend.
If no stack profiler is activated, this function has no effect.
displayhook(object, /)
Print an object to sys.stdout and also save it in builtins._
exc_info()
Return current exception information: (type, value, traceback).
Return information about the most recent exception caught by an except
clause in the current stack frame or in an older stack frame.
excepthook(exctype, value, traceback, /)
Handle an exception by displaying it with a traceback on sys.stderr.
exception()
Return the current exception.
Return the most recent exception caught by an except clause
in the current stack frame or in an older stack frame, or None
if no such exception exists.
exit(status=None, /)
Exit the interpreter by raising SystemExit(status).
If the status is omitted or None, it defaults to zero (i.e., success).
If the status is an integer, it will be used as the system exit status.
If it is another kind of object, it will be printed and the system
exit status will be one (i.e., failure).
get_asyncgen_hooks()
Return the installed asynchronous generators hooks.
This returns a namedtuple of the form (firstiter, finalizer).
get_coroutine_origin_tracking_depth()
Check status of origin tracking for coroutine objects in this thread.
get_int_max_str_digits()
Return the maximum string digits limit for non-binary int<->str conversions.
getallocatedblocks()
Return the number of memory blocks currently allocated.
getdefaultencoding()
Return the current default encoding used by the Unicode implementation.
getfilesystemencodeerrors()
Return the error mode used Unicode to OS filename conversion.
getfilesystemencoding()
Return the encoding used to convert Unicode filenames to OS filenames.
getprofile()
Return the profiling function set with sys.setprofile.
See the profiler chapter in the library manual.
getrecursionlimit()
Return the current value of the recursion limit.
The recursion limit is the maximum depth of the Python interpreter
stack. This limit prevents infinite recursion from causing an overflow
of the C stack and crashing Python.
getrefcount(object, /)
Return the reference count of object.
The count returned is generally one higher than you might expect,
because it includes the (temporary) reference as an argument to
getrefcount().
getsizeof(...)
getsizeof(object [, default]) -> int
Return the size of object in bytes.
getswitchinterval()
Return the current thread switch interval; see sys.setswitchinterval().
gettrace()
Return the global debug tracing function set with sys.settrace.
See the debugger chapter in the library manual.
getunicodeinternedsize()
Return the number of elements of the unicode interned dictionary
getwindowsversion()
Return info about the running version of Windows as a named tuple.
The members are named: major, minor, build, platform, service_pack,
service_pack_major, service_pack_minor, suite_mask, product_type and
platform_version. For backward compatibility, only the first 5 items
are available by indexing. All elements are numbers, except
service_pack and platform_type which are strings, and platform_version
which is a 3-tuple. Platform is always 2. Product_type may be 1 for a
workstation, 2 for a domain controller, 3 for a server.
Platform_version is a 3-tuple containing a version number that is
intended for identifying the OS rather than feature detection.
intern(string, /)
``Intern'' the given string.
This enters the string in the (global) table of interned strings whose
purpose is to speed up dictionary lookups. Return the string itself or
the previously interned string object with the same value.
is_finalizing()
Return True if Python is exiting.
is_stack_trampoline_active()
Return *True* if a stack profiler trampoline is active.
set_asyncgen_hooks(...)
set_asyncgen_hooks([firstiter] [, finalizer])
Set a finalizer for async generators objects.
set_coroutine_origin_tracking_depth(depth)
Enable or disable origin tracking for coroutine objects in this thread.
Coroutine objects will track 'depth' frames of traceback information
about where they came from, available in their cr_origin attribute.
Set a depth of 0 to disable.
set_int_max_str_digits(maxdigits)
Set the maximum string digits limit for non-binary int<->str conversions.
setprofile(...)
setprofile(function)
Set the profiling function. It will be called on each function call
and return. See the profiler chapter in the library manual.
setrecursionlimit(limit, /)
Set the maximum depth of the Python interpreter stack to n.
This limit prevents infinite recursion from causing an overflow of the C
stack and crashing Python. The highest possible limit is platform-
dependent.
setswitchinterval(interval, /)
Set the ideal thread switching delay inside the Python interpreter.
The actual frequency of switching threads can be lower if the
interpreter executes long sequences of uninterruptible code
(this is implementation-specific and workload-dependent).
The parameter must represent the desired switching delay in seconds
A typical value is 0.005 (5 milliseconds).
settrace(...)
settrace(function)
Set the global debug tracing function. It will be called on each
function call. See the debugger chapter in the library manual.
unraisablehook(unraisable, /)
Handle an unraisable exception.
The unraisable argument has the following attributes:
* exc_type: Exception type.
* exc_value: Exception value, can be None.
* exc_traceback: Exception traceback, can be None.
* err_msg: Error message, can be None.
* object: Object causing the exception, can be None.
DATA
__stderr__ = <_io.TextIOWrapper name='<stderr>' mode='w' encoding='cp1...
__stdin__ = <_io.TextIOWrapper name='<stdin>' mode='r' encoding='utf-8...
__stdout__ = <_io.TextIOWrapper name='<stdout>' mode='w' encoding='cp1...
api_version = 1013
argv = [r'f:\JoeyCodes\PyDocs\py_docs.py', '--worker', 'fractions', r'...
base_exec_prefix = r'C:\Users\Youse\AppData\Local\Programs\Python\Pyth...
base_prefix = r'C:\Users\Youse\AppData\Local\Programs\Python\Python312...
builtin_module_names = ('_abc', '_ast', '_bisect', '_blake2', '_codecs...
byteorder = 'little'
copyright = 'Copyright (c) 2001-2023 Python Software Foundati...ematis...
dllhandle = 140727031824384
dont_write_bytecode = False
exec_prefix = r'C:\Users\Youse\AppData\Local\Programs\Python\Python312...
executable = r'C:\Users\Youse\AppData\Local\Programs\Python\Python312\...
flags = sys.flags(debug=0, inspect=0, interactive=0, opt...ding=0, saf...
float_info = sys.float_info(max=1.7976931348623157e+308, max_...epsilo...
float_repr_style = 'short'
hash_info = sys.hash_info(width=64, modulus=2305843009213693...iphash1...
hexversion = 51119856
implementation = namespace(name='cpython', cache_tag='cpython-312...as...
int_info = sys.int_info(bits_per_digit=30, sizeof_digit=4, ..._str_dig...
maxsize = 9223372036854775807
maxunicode = 1114111
meta_path = [<_distutils_hack.DistutilsMetaFinder object>, <class '_fr...
modules = {'__future__': <module '__future__' from 'C:\\Users\\Youse\\...
orig_argv = [r'C:\Users\Youse\AppData\Local\Programs\Python\Python312\...
path = [r'f:\JoeyCodes\PyDocs', r'C:\Users\Youse\AppData\Local\Program...
path_hooks = [<class 'zipimport.zipimporter'>, <function FileFinder.pa...
path_importer_cache = {r'C:\Users\Youse\AppData\Local\Programs\Python\...
platform = 'win32'
platlibdir = 'DLLs'
prefix = r'C:\Users\Youse\AppData\Local\Programs\Python\Python312'
pycache_prefix = None
stderr = <_io.TextIOWrapper name='<stderr>' mode='w' encoding='cp1252'...
stdin = <_io.TextIOWrapper name='<stdin>' mode='r' encoding='utf-8'>
stdlib_module_names = frozenset({'__future__', '_abc', '_aix_support',...
stdout = <_io.TextIOWrapper name='<stdout>' mode='w' encoding='cp1252'...
thread_info = sys.thread_info(name='nt', lock=None, version=None)
version = '3.12.6 (tags/v3.12.6:a4a2d2b, Sep 6 2024, 20:11:23) [MSC v...
version_info = sys.version_info(major=3, minor=12, micro=6, releaselev...
warnoptions = []
winver = '3.12'
FILE
(built-in)