traceback API Reference
Full documentation for traceback (Standard Library / Native)
traceback.FrameSummary
Python Library Documentation: class FrameSummary in module traceback class FrameSummary(builtins.object) | FrameSummary(filename, lineno, name, *, lookup_line=True, locals=None, line=None, end_lineno=None, colno=None, end_colno=None) | | Information about a single frame from a traceback. | | - :attr:`filename` The filename for the frame. | - :attr:`lineno` The line within filename for the frame that was | active when the frame was captured. | - :attr:`name` The name of the function or method that was executing | when the frame was captured. | - :attr:`line` The text from the linecache module for the | of code that was running when the frame was captured. | - :attr:`locals` Either None if locals were not supplied, or a dict | mapping the name to the repr() of the variable. | | Methods defined here: | | __eq__(self, other) | Return self==value. | | __getitem__(self, pos) | | __init__(self, filename, lineno, name, *, lookup_line=True, locals=None, line=None, end_lineno=None, colno=None, end_colno=None) | Construct a FrameSummary. | | :param lookup_line: If True, `linecache` is consulted for the source | code line. Otherwise, the line will be looked up when first needed. | :param locals: If supplied the frame locals, which will be captured as | object representations. | :param line: If provided, use this instead of looking up the line in | the linecache. | | __iter__(self) | | __len__(self) | | __repr__(self) | Return repr(self). | | ---------------------------------------------------------------------- | Readonly properties defined here: | | line | | ---------------------------------------------------------------------- | Data descriptors defined here: | | colno | | end_colno | | end_lineno | | filename | | lineno | | locals | | name | | ---------------------------------------------------------------------- | Data and other attributes defined here: | | __hash__ = None
traceback.StackSummary
Python Library Documentation: class StackSummary in module traceback class StackSummary(builtins.list) | StackSummary(iterable=(), /) | | A list of FrameSummary objects, representing a stack of frames. | | Method resolution order: | StackSummary | builtins.list | builtins.object | | Methods defined here: | | format(self) | Format the stack ready for printing. | | Returns a list of strings ready for printing. Each string in the | resulting list corresponds to a single frame from the stack. | Each string ends in a newline; the strings may contain internal | newlines as well, for those items with source text lines. | | For long sequences of the same frame and line, the first few | repetitions are shown, followed by a summary line stating the exact | number of further repetitions. | | format_frame_summary(self, frame_summary) | Format the lines for a single FrameSummary. | | Returns a string representing one frame involved in the stack. This | gets called for every frame to be printed in the stack summary. | | ---------------------------------------------------------------------- | Class methods defined here: | | extract(frame_gen, *, limit=None, lookup_lines=True, capture_locals=False) | Create a StackSummary from a traceback or stack object. | | :param frame_gen: A generator that yields (frame, lineno) tuples | whose summaries are to be included in the stack. | :param limit: None to include all frames or the number of frames to | include. | :param lookup_lines: If True, lookup lines for each frame immediately, | otherwise lookup is deferred until the frame is rendered. | :param capture_locals: If True, the local variables from each frame will | be captured as object representations into the FrameSummary. | | from_list(a_list) | Create a StackSummary object from a supplied list of | FrameSummary objects or old-style list of tuples. | | ---------------------------------------------------------------------- | Data descriptors defined here: | | __dict__ | dictionary for instance variables | | __weakref__ | list of weak references to the object | | ---------------------------------------------------------------------- | Methods inherited from builtins.list: | | __add__(self, value, /) | Return self+value. | | __contains__(self, key, /) | Return bool(key in self). | | __delitem__(self, key, /) | Delete self[key]. | | __eq__(self, value, /) | Return self==value. | | __ge__(self, value, /) | Return self>=value. | | __getattribute__(self, name, /) | Return getattr(self, name). | | __getitem__(self, index, /) | Return self[index]. | | __gt__(self, value, /) | Return self>value. | | __iadd__(self, value, /) | Implement self+=value. | | __imul__(self, value, /) | Implement self*=value. | | __init__(self, /, *args, **kwargs) | Initialize self. See help(type(self)) for accurate signature. | | __iter__(self, /) | Implement iter(self). | | __le__(self, value, /) | Return self<=value. | | __len__(self, /) | Return len(self). | | __lt__(self, value, /) | Return self<value. | | __mul__(self, value, /) | Return self*value. | | __ne__(self, value, /) | Return self!=value. | | __repr__(self, /) | Return repr(self). | | __reversed__(self, /) | Return a reverse iterator over the list. | | __rmul__(self, value, /) | Return value*self. | | __setitem__(self, key, value, /) | Set self[key] to value. | | __sizeof__(self, /) | Return the size of the list in memory, in bytes. | | append(self, object, /) | Append object to the end of the list. | | clear(self, /) | Remove all items from list. | | copy(self, /) | Return a shallow copy of the list. | | count(self, value, /) | Return number of occurrences of value. | | extend(self, iterable, /) | Extend list by appending elements from the iterable. | | index(self, value, start=0, stop=9223372036854775807, /) | Return first index of value. | | Raises ValueError if the value is not present. | | insert(self, index, object, /) | Insert object before index. | | pop(self, index=-1, /) | Remove and return item at index (default last). | | Raises IndexError if list is empty or index is out of range. | | remove(self, value, /) | Remove first occurrence of value. | | Raises ValueError if the value is not present. | | reverse(self, /) | Reverse *IN PLACE*. | | sort(self, /, *, key=None, reverse=False) | Sort the list in ascending order and return None. | | The sort is in-place (i.e. the list itself is modified) and stable (i.e. the | order of two equal elements is maintained). | | If a key function is given, apply it once to each list item and sort them, | ascending or descending, according to their function values. | | The reverse flag can be set to sort in descending order. | | ---------------------------------------------------------------------- | Class methods inherited from builtins.list: | | __class_getitem__(...) | See PEP 585 | | ---------------------------------------------------------------------- | Static methods inherited from builtins.list: | | __new__(*args, **kwargs) class method of builtins.list | Create and return a new object. See help(type) for accurate signature. | | ---------------------------------------------------------------------- | Data and other attributes inherited from builtins.list: | | __hash__ = None
traceback.TracebackException
Python Library Documentation: class TracebackException in module traceback class TracebackException(builtins.object) | TracebackException(exc_type, exc_value, exc_traceback, *, limit=None, lookup_lines=True, capture_locals=False, compact=False, max_group_width=15, max_group_depth=10, _seen=None) | | An exception ready for rendering. | | The traceback module captures enough attributes from the original exception | to this intermediary form to ensure that no references are held, while | still being able to fully print or format it. | | max_group_width and max_group_depth control the formatting of exception | groups. The depth refers to the nesting level of the group, and the width | refers to the size of a single exception group's exceptions array. The | formatted output is truncated when either limit is exceeded. | | Use `from_exception` to create TracebackException instances from exception | objects, or the constructor to create TracebackException instances from | individual components. | | - :attr:`__cause__` A TracebackException of the original *__cause__*. | - :attr:`__context__` A TracebackException of the original *__context__*. | - :attr:`exceptions` For exception groups - a list of TracebackException | instances for the nested *exceptions*. ``None`` for other exceptions. | - :attr:`__suppress_context__` The *__suppress_context__* value from the | original exception. | - :attr:`stack` A `StackSummary` representing the traceback. | - :attr:`exc_type` The class of the original traceback. | - :attr:`filename` For syntax errors - the filename where the error | occurred. | - :attr:`lineno` For syntax errors - the linenumber where the error | occurred. | - :attr:`end_lineno` For syntax errors - the end linenumber where the error | occurred. Can be `None` if not present. | - :attr:`text` For syntax errors - the text where the error | occurred. | - :attr:`offset` For syntax errors - the offset into the text where the | error occurred. | - :attr:`end_offset` For syntax errors - the end offset into the text where | the error occurred. Can be `None` if not present. | - :attr:`msg` For syntax errors - the compiler error message. | | Methods defined here: | | __eq__(self, other) | Return self==value. | | __init__(self, exc_type, exc_value, exc_traceback, *, limit=None, lookup_lines=True, capture_locals=False, compact=False, max_group_width=15, max_group_depth=10, _seen=None) | Initialize self. See help(type(self)) for accurate signature. | | __str__(self) | Return str(self). | | format(self, *, chain=True, _ctx=None) | Format the exception. | | If chain is not *True*, *__cause__* and *__context__* will not be formatted. | | The return value is a generator of strings, each ending in a newline and | some containing internal newlines. `print_exception` is a wrapper around | this method which just prints the lines to a file. | | The message indicating which exception occurred is always the last | string in the output. | | format_exception_only(self) | Format the exception part of the traceback. | | The return value is a generator of strings, each ending in a newline. | | Generator yields the exception message. | For :exc:`SyntaxError` exceptions, it | also yields (before the exception message) | several lines that (when printed) | display detailed information about where the syntax error occurred. | Following the message, generator also yields | all the exception's ``__notes__``. | | print(self, *, file=None, chain=True) | Print the result of self.format(chain=chain) to 'file'. | | ---------------------------------------------------------------------- | Class methods defined here: | | from_exception(exc, *args, **kwargs) | Create a TracebackException from an exception. | | ---------------------------------------------------------------------- | Data descriptors defined here: | | __dict__ | dictionary for instance variables | | __weakref__ | list of weak references to the object | | ---------------------------------------------------------------------- | Data and other attributes defined here: | | __hash__ = None
traceback.clear_frames
Python Library Documentation: function clear_frames in module traceback
clear_frames(tb)
Clear all references to local variables in the frames of a traceback.
traceback.collections
Python Library Documentation: package collections
NAME
collections
MODULE REFERENCE
https://docs.python.org/3.12/library/collections.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 implements specialized container datatypes providing
alternatives to Python's general purpose built-in containers, dict,
list, set, and tuple.
* namedtuple factory function for creating tuple subclasses with named fields
* deque list-like container with fast appends and pops on either end
* ChainMap dict-like class for creating a single view of multiple mappings
* Counter dict subclass for counting hashable objects
* OrderedDict dict subclass that remembers the order entries were added
* defaultdict dict subclass that calls a factory function to supply missing values
* UserDict wrapper around dictionary objects for easier dict subclassing
* UserList wrapper around list objects for easier list subclassing
* UserString wrapper around string objects for easier string subclassing
PACKAGE CONTENTS
abc
SUBMODULES
_collections_abc
CLASSES
builtins.dict(builtins.object)
Counter
OrderedDict
defaultdict
builtins.object
deque
collections.abc.MutableMapping(collections.abc.Mapping)
ChainMap
UserDict
collections.abc.MutableSequence(collections.abc.Sequence)
UserList
collections.abc.Sequence(collections.abc.Reversible, collections.abc.Collection)
UserString
class ChainMap(collections.abc.MutableMapping)
| ChainMap(*maps)
|
| A ChainMap groups multiple dicts (or other mappings) together
| to create a single, updateable view.
|
| The underlying mappings are stored in a list. That list is public and can
| be accessed or updated using the *maps* attribute. There is no other
| state.
|
| Lookups search the underlying mappings successively until a key is found.
| In contrast, writes, updates, and deletions only operate on the first
| mapping.
|
| Method resolution order:
| ChainMap
| collections.abc.MutableMapping
| collections.abc.Mapping
| collections.abc.Collection
| collections.abc.Sized
| collections.abc.Iterable
| collections.abc.Container
| builtins.object
|
| Methods defined here:
|
| __bool__(self)
|
| __contains__(self, key)
|
| __copy__ = copy(self)
|
| __delitem__(self, key)
|
| __getitem__(self, key)
|
| __init__(self, *maps)
| Initialize a ChainMap by setting *maps* to the given mappings.
| If no mappings are provided, a single empty dictionary is used.
|
| __ior__(self, other)
|
| __iter__(self)
|
| __len__(self)
|
| __missing__(self, key)
|
| __or__(self, other)
| Return self|value.
|
| __repr__(self)
| Return repr(self).
|
| __ror__(self, other)
| Return value|self.
|
| __setitem__(self, key, value)
|
| clear(self)
| Clear maps[0], leaving maps[1:] intact.
|
| copy(self)
| New ChainMap or subclass with a new copy of maps[0] and refs to maps[1:]
|
| get(self, key, default=None)
| D.get(k[,d]) -> D[k] if k in D, else d. d defaults to None.
|
| new_child(self, m=None, **kwargs)
| New ChainMap with a new map followed by all previous maps.
| If no map is provided, an empty dict is used.
| Keyword arguments update the map or new empty dict.
|
| pop(self, key, *args)
| Remove *key* from maps[0] and return its value. Raise KeyError if *key* not in maps[0].
|
| popitem(self)
| Remove and return an item pair from maps[0]. Raise KeyError is maps[0] is empty.
|
| ----------------------------------------------------------------------
| Class methods defined here:
|
| fromkeys(iterable, *args)
| Create a ChainMap with a single dict created from the iterable.
|
| ----------------------------------------------------------------------
| Readonly properties defined here:
|
| parents
| New ChainMap from maps[1:].
|
| ----------------------------------------------------------------------
| Data descriptors defined here:
|
| __dict__
| dictionary for instance variables
|
| __weakref__
| list of weak references to the object
|
| ----------------------------------------------------------------------
| Data and other attributes defined here:
|
| __abstractmethods__ = frozenset()
|
| ----------------------------------------------------------------------
| Methods inherited from collections.abc.MutableMapping:
|
| setdefault(self, key, default=None)
| D.setdefault(k[,d]) -> D.get(k,d), also set D[k]=d if k not in D
|
| update(self, other=(), /, **kwds)
| D.update([E, ]**F) -> None. Update D from mapping/iterable E and F.
| If E present and has a .keys() method, does: for k in E: D[k] = E[k]
| If E present and lacks .keys() method, does: for (k, v) in E: D[k] = v
| In either case, this is followed by: for k, v in F.items(): D[k] = v
|
| ----------------------------------------------------------------------
| Methods inherited from collections.abc.Mapping:
|
| __eq__(self, other)
| Return self==value.
|
| items(self)
| D.items() -> a set-like object providing a view on D's items
|
| keys(self)
| D.keys() -> a set-like object providing a view on D's keys
|
| values(self)
| D.values() -> an object providing a view on D's values
|
| ----------------------------------------------------------------------
| Data and other attributes inherited from collections.abc.Mapping:
|
| __hash__ = None
|
| __reversed__ = None
|
| ----------------------------------------------------------------------
| Class methods inherited from collections.abc.Collection:
|
| __subclasshook__(C)
| Abstract classes can override this to customize issubclass().
|
| This is invoked early on by abc.ABCMeta.__subclasscheck__().
| It should return True, False or NotImplemented. If it returns
| NotImplemented, the normal algorithm is used. Otherwise, it
| overrides the normal algorithm (and the outcome is cached).
|
| ----------------------------------------------------------------------
| Class methods inherited from collections.abc.Iterable:
|
| __class_getitem__ = GenericAlias(...)
| Represent a PEP 585 generic type
|
| E.g. for t = list[int], t.__origin__ is list and t.__args__ is (int,).
class Counter(builtins.dict)
| Counter(iterable=None, /, **kwds)
|
| Dict subclass for counting hashable items. Sometimes called a bag
| or multiset. Elements are stored as dictionary keys and their counts
| are stored as dictionary values.
|
| >>> c = Counter('abcdeabcdabcaba') # count elements from a string
|
| >>> c.most_common(3) # three most common elements
| [('a', 5), ('b', 4), ('c', 3)]
| >>> sorted(c) # list all unique elements
| ['a', 'b', 'c', 'd', 'e']
| >>> ''.join(sorted(c.elements())) # list elements with repetitions
| 'aaaaabbbbcccdde'
| >>> sum(c.values()) # total of all counts
| 15
|
| >>> c['a'] # count of letter 'a'
| 5
| >>> for elem in 'shazam': # update counts from an iterable
| ... c[elem] += 1 # by adding 1 to each element's count
| >>> c['a'] # now there are seven 'a'
| 7
| >>> del c['b'] # remove all 'b'
| >>> c['b'] # now there are zero 'b'
| 0
|
| >>> d = Counter('simsalabim') # make another counter
| >>> c.update(d) # add in the second counter
| >>> c['a'] # now there are nine 'a'
| 9
|
| >>> c.clear() # empty the counter
| >>> c
| Counter()
|
| Note: If a count is set to zero or reduced to zero, it will remain
| in the counter until the entry is deleted or the counter is cleared:
|
| >>> c = Counter('aaabbc')
| >>> c['b'] -= 2 # reduce the count of 'b' by two
| >>> c.most_common() # 'b' is still in, but its count is zero
| [('a', 3), ('c', 1), ('b', 0)]
|
| Method resolution order:
| Counter
| builtins.dict
| builtins.object
|
| Methods defined here:
|
| __add__(self, other)
| Add counts from two counters.
|
| >>> Counter('abbb') + Counter('bcc')
| Counter({'b': 4, 'c': 2, 'a': 1})
|
| __and__(self, other)
| Intersection is the minimum of corresponding counts.
|
| >>> Counter('abbb') & Counter('bcc')
| Counter({'b': 1})
|
| __delitem__(self, elem)
| Like dict.__delitem__() but does not raise KeyError for missing values.
|
| __eq__(self, other)
| True if all counts agree. Missing counts are treated as zero.
|
| __ge__(self, other)
| True if all counts in self are a superset of those in other.
|
| __gt__(self, other)
| True if all counts in self are a proper superset of those in other.
|
| __iadd__(self, other)
| Inplace add from another counter, keeping only positive counts.
|
| >>> c = Counter('abbb')
| >>> c += Counter('bcc')
| >>> c
| Counter({'b': 4, 'c': 2, 'a': 1})
|
| __iand__(self, other)
| Inplace intersection is the minimum of corresponding counts.
|
| >>> c = Counter('abbb')
| >>> c &= Counter('bcc')
| >>> c
| Counter({'b': 1})
|
| __init__(self, iterable=None, /, **kwds)
| Create a new, empty Counter object. And if given, count elements
| from an input iterable. Or, initialize the count from another mapping
| of elements to their counts.
|
| >>> c = Counter() # a new, empty counter
| >>> c = Counter('gallahad') # a new counter from an iterable
| >>> c = Counter({'a': 4, 'b': 2}) # a new counter from a mapping
| >>> c = Counter(a=4, b=2) # a new counter from keyword args
|
| __ior__(self, other)
| Inplace union is the maximum of value from either counter.
|
| >>> c = Counter('abbb')
| >>> c |= Counter('bcc')
| >>> c
| Counter({'b': 3, 'c': 2, 'a': 1})
|
| __isub__(self, other)
| Inplace subtract counter, but keep only results with positive counts.
|
| >>> c = Counter('abbbc')
| >>> c -= Counter('bccd')
| >>> c
| Counter({'b': 2, 'a': 1})
|
| __le__(self, other)
| True if all counts in self are a subset of those in other.
|
| __lt__(self, other)
| True if all counts in self are a proper subset of those in other.
|
| __missing__(self, key)
| The count of elements not in the Counter is zero.
|
| __ne__(self, other)
| True if any counts disagree. Missing counts are treated as zero.
|
| __neg__(self)
| Subtracts from an empty counter. Strips positive and zero counts,
| and flips the sign on negative counts.
|
| __or__(self, other)
| Union is the maximum of value in either of the input counters.
|
| >>> Counter('abbb') | Counter('bcc')
| Counter({'b': 3, 'c': 2, 'a': 1})
|
| __pos__(self)
| Adds an empty counter, effectively stripping negative and zero counts
|
| __reduce__(self)
| Helper for pickle.
|
| __repr__(self)
| Return repr(self).
|
| __sub__(self, other)
| Subtract count, but keep only results with positive counts.
|
| >>> Counter('abbbc') - Counter('bccd')
| Counter({'b': 2, 'a': 1})
|
| copy(self)
| Return a shallow copy.
|
| elements(self)
| Iterator over elements repeating each as many times as its count.
|
| >>> c = Counter('ABCABC')
| >>> sorted(c.elements())
| ['A', 'A', 'B', 'B', 'C', 'C']
|
| Knuth's example for prime factors of 1836: 2**2 * 3**3 * 17**1
|
| >>> import math
| >>> prime_factors = Counter({2: 2, 3: 3, 17: 1})
| >>> math.prod(prime_factors.elements())
| 1836
|
| Note, if an element's count has been set to zero or is a negative
| number, elements() will ignore it.
|
| most_common(self, n=None)
| List the n most common elements and their counts from the most
| common to the least. If n is None, then list all element counts.
|
| >>> Counter('abracadabra').most_common(3)
| [('a', 5), ('b', 2), ('r', 2)]
|
| subtract(self, iterable=None, /, **kwds)
| Like dict.update() but subtracts counts instead of replacing them.
| Counts can be reduced below zero. Both the inputs and outputs are
| allowed to contain zero and negative counts.
|
| Source can be an iterable, a dictionary, or another Counter instance.
|
| >>> c = Counter('which')
| >>> c.subtract('witch') # subtract elements from another iterable
| >>> c.subtract(Counter('watch')) # subtract elements from another counter
| >>> c['h'] # 2 in which, minus 1 in witch, minus 1 in watch
| 0
| >>> c['w'] # 1 in which, minus 1 in witch, minus 1 in watch
| -1
|
| total(self)
| Sum of the counts
|
| update(self, iterable=None, /, **kwds)
| Like dict.update() but add counts instead of replacing them.
|
| Source can be an iterable, a dictionary, or another Counter instance.
|
| >>> c = Counter('which')
| >>> c.update('witch') # add elements from another iterable
| >>> d = Counter('watch')
| >>> c.update(d) # add elements from another counter
| >>> c['h'] # four 'h' in which, witch, and watch
| 4
|
| ----------------------------------------------------------------------
| Class methods defined here:
|
| fromkeys(iterable, v=None)
| Create a new dictionary with keys from iterable and values set to value.
|
| ----------------------------------------------------------------------
| Data descriptors defined here:
|
| __dict__
| dictionary for instance variables
|
| __weakref__
| list of weak references to the object
|
| ----------------------------------------------------------------------
| Data and other attributes defined here:
|
| __hash__ = None
|
| ----------------------------------------------------------------------
| Methods inherited from builtins.dict:
|
| __contains__(self, key, /)
| True if the dictionary has the specified key, else False.
|
| __getattribute__(self, name, /)
| Return getattr(self, name).
|
| __getitem__(self, key, /)
| Return self[key].
|
| __iter__(self, /)
| Implement iter(self).
|
| __len__(self, /)
| Return len(self).
|
| __reversed__(self, /)
| Return a reverse iterator over the dict keys.
|
| __ror__(self, value, /)
| Return value|self.
|
| __setitem__(self, key, value, /)
| Set self[key] to value.
|
| __sizeof__(...)
| D.__sizeof__() -> size of D in memory, in bytes
|
| clear(...)
| D.clear() -> None. Remove all items from D.
|
| get(self, key, default=None, /)
| Return the value for key if key is in the dictionary, else default.
|
| items(...)
| D.items() -> a set-like object providing a view on D's items
|
| keys(...)
| D.keys() -> a set-like object providing a view on D's keys
|
| pop(...)
| D.pop(k[,d]) -> v, remove specified key and return the corresponding value.
|
| If the key is not found, return the default if given; otherwise,
| raise a KeyError.
|
| popitem(self, /)
| Remove and return a (key, value) pair as a 2-tuple.
|
| Pairs are returned in LIFO (last-in, first-out) order.
| Raises KeyError if the dict is empty.
|
| setdefault(self, key, default=None, /)
| Insert key with a value of default if key is not in the dictionary.
|
| Return the value for key if key is in the dictionary, else default.
|
| values(...)
| D.values() -> an object providing a view on D's values
|
| ----------------------------------------------------------------------
| Class methods inherited from builtins.dict:
|
| __class_getitem__(...)
| See PEP 585
|
| ----------------------------------------------------------------------
| Static methods inherited from builtins.dict:
|
| __new__(*args, **kwargs) class method of builtins.dict
| Create and return a new object. See help(type) for accurate signature.
class OrderedDict(builtins.dict)
| Dictionary that remembers insertion order
|
| Method resolution order:
| OrderedDict
| builtins.dict
| builtins.object
|
| Methods defined here:
|
| __delitem__(self, key, /)
| Delete self[key].
|
| __eq__(self, value, /)
| Return self==value.
|
| __ge__(self, value, /)
| Return self>=value.
|
| __gt__(self, value, /)
| Return self>value.
|
| __init__(self, /, *args, **kwargs)
| Initialize self. See help(type(self)) for accurate signature.
|
| __ior__(self, value, /)
| Return self|=value.
|
| __iter__(self, /)
| Implement iter(self).
|
| __le__(self, value, /)
| Return self<=value.
|
| __lt__(self, value, /)
| Return self<value.
|
| __ne__(self, value, /)
| Return self!=value.
|
| __or__(self, value, /)
| Return self|value.
|
| __reduce__(...)
| Return state information for pickling
|
| __repr__(self, /)
| Return repr(self).
|
| __reversed__(...)
| od.__reversed__() <==> reversed(od)
|
| __ror__(self, value, /)
| Return value|self.
|
| __setitem__(self, key, value, /)
| Set self[key] to value.
|
| __sizeof__(...)
| D.__sizeof__() -> size of D in memory, in bytes
|
| clear(...)
| od.clear() -> None. Remove all items from od.
|
| copy(...)
| od.copy() -> a shallow copy of od
|
| items(...)
| D.items() -> a set-like object providing a view on D's items
|
| keys(...)
| D.keys() -> a set-like object providing a view on D's keys
|
| move_to_end(self, /, key, last=True)
| Move an existing element to the end (or beginning if last is false).
|
| Raise KeyError if the element does not exist.
|
| pop(...)
| od.pop(key[,default]) -> v, remove specified key and return the corresponding value.
|
| If the key is not found, return the default if given; otherwise,
| raise a KeyError.
|
| popitem(self, /, last=True)
| Remove and return a (key, value) pair from the dictionary.
|
| Pairs are returned in LIFO order if last is true or FIFO order if false.
|
| setdefault(self, /, key, default=None)
| Insert key with a value of default if key is not in the dictionary.
|
| Return the value for key if key is in the dictionary, else default.
|
| update(...)
| D.update([E, ]**F) -> None. Update D from dict/iterable E and F.
| If E is present and has a .keys() method, then does: for k in E: D[k] = E[k]
| If E is present and lacks a .keys() method, then does: for k, v in E: D[k] = v
| In either case, this is followed by: for k in F: D[k] = F[k]
|
| values(...)
| D.values() -> an object providing a view on D's values
|
| ----------------------------------------------------------------------
| Class methods defined here:
|
| fromkeys(iterable, value=None)
| Create a new ordered dictionary with keys from iterable and values set to value.
|
| ----------------------------------------------------------------------
| Data descriptors defined here:
|
| __dict__
|
| ----------------------------------------------------------------------
| Data and other attributes defined here:
|
| __hash__ = None
|
| ----------------------------------------------------------------------
| Methods inherited from builtins.dict:
|
| __contains__(self, key, /)
| True if the dictionary has the specified key, else False.
|
| __getattribute__(self, name, /)
| Return getattr(self, name).
|
| __getitem__(self, key, /)
| Return self[key].
|
| __len__(self, /)
| Return len(self).
|
| get(self, key, default=None, /)
| Return the value for key if key is in the dictionary, else default.
|
| ----------------------------------------------------------------------
| Class methods inherited from builtins.dict:
|
| __class_getitem__(...)
| See PEP 585
|
| ----------------------------------------------------------------------
| Static methods inherited from builtins.dict:
|
| __new__(*args, **kwargs) class method of builtins.dict
| Create and return a new object. See help(type) for accurate signature.
class UserDict(collections.abc.MutableMapping)
| UserDict(dict=None, /, **kwargs)
|
| Method resolution order:
| UserDict
| collections.abc.MutableMapping
| collections.abc.Mapping
| collections.abc.Collection
| collections.abc.Sized
| collections.abc.Iterable
| collections.abc.Container
| builtins.object
|
| Methods defined here:
|
| __contains__(self, key)
| # Modify __contains__ and get() to work like dict
| # does when __missing__ is present.
|
| __copy__(self)
|
| __delitem__(self, key)
|
| __getitem__(self, key)
|
| __init__(self, dict=None, /, **kwargs)
| Initialize self. See help(type(self)) for accurate signature.
|
| __ior__(self, other)
|
| __iter__(self)
|
| __len__(self)
|
| __or__(self, other)
| Return self|value.
|
| __repr__(self)
| Return repr(self).
|
| __ror__(self, other)
| Return value|self.
|
| __setitem__(self, key, item)
|
| copy(self)
|
| get(self, key, default=None)
| D.get(k[,d]) -> D[k] if k in D, else d. d defaults to None.
|
| ----------------------------------------------------------------------
| Class methods defined here:
|
| fromkeys(iterable, value=None)
|
| ----------------------------------------------------------------------
| Data descriptors defined here:
|
| __dict__
| dictionary for instance variables
|
| __weakref__
| list of weak references to the object
|
| ----------------------------------------------------------------------
| Data and other attributes defined here:
|
| __abstractmethods__ = frozenset()
|
| ----------------------------------------------------------------------
| Methods inherited from collections.abc.MutableMapping:
|
| clear(self)
| D.clear() -> None. Remove all items from D.
|
| pop(self, key, default=<object object at 0x00000245257681F0>)
| D.pop(k[,d]) -> v, remove specified key and return the corresponding value.
| If key is not found, d is returned if given, otherwise KeyError is raised.
|
| popitem(self)
| D.popitem() -> (k, v), remove and return some (key, value) pair
| as a 2-tuple; but raise KeyError if D is empty.
|
| setdefault(self, key, default=None)
| D.setdefault(k[,d]) -> D.get(k,d), also set D[k]=d if k not in D
|
| update(self, other=(), /, **kwds)
| D.update([E, ]**F) -> None. Update D from mapping/iterable E and F.
| If E present and has a .keys() method, does: for k in E: D[k] = E[k]
| If E present and lacks .keys() method, does: for (k, v) in E: D[k] = v
| In either case, this is followed by: for k, v in F.items(): D[k] = v
|
| ----------------------------------------------------------------------
| Methods inherited from collections.abc.Mapping:
|
| __eq__(self, other)
| Return self==value.
|
| items(self)
| D.items() -> a set-like object providing a view on D's items
|
| keys(self)
| D.keys() -> a set-like object providing a view on D's keys
|
| values(self)
| D.values() -> an object providing a view on D's values
|
| ----------------------------------------------------------------------
| Data and other attributes inherited from collections.abc.Mapping:
|
| __hash__ = None
|
| __reversed__ = None
|
| ----------------------------------------------------------------------
| Class methods inherited from collections.abc.Collection:
|
| __subclasshook__(C)
| Abstract classes can override this to customize issubclass().
|
| This is invoked early on by abc.ABCMeta.__subclasscheck__().
| It should return True, False or NotImplemented. If it returns
| NotImplemented, the normal algorithm is used. Otherwise, it
| overrides the normal algorithm (and the outcome is cached).
|
| ----------------------------------------------------------------------
| Class methods inherited from collections.abc.Iterable:
|
| __class_getitem__ = GenericAlias(...)
| Represent a PEP 585 generic type
|
| E.g. for t = list[int], t.__origin__ is list and t.__args__ is (int,).
class UserList(collections.abc.MutableSequence)
| UserList(initlist=None)
|
| A more or less complete user-defined wrapper around list objects.
|
| Method resolution order:
| UserList
| collections.abc.MutableSequence
| collections.abc.Sequence
| collections.abc.Reversible
| collections.abc.Collection
| collections.abc.Sized
| collections.abc.Iterable
| collections.abc.Container
| builtins.object
|
| Methods defined here:
|
| __add__(self, other)
|
| __contains__(self, item)
|
| __copy__(self)
|
| __delitem__(self, i)
|
| __eq__(self, other)
| Return self==value.
|
| __ge__(self, other)
| Return self>=value.
|
| __getitem__(self, i)
|
| __gt__(self, other)
| Return self>value.
|
| __iadd__(self, other)
|
| __imul__(self, n)
|
| __init__(self, initlist=None)
| Initialize self. See help(type(self)) for accurate signature.
|
| __le__(self, other)
| Return self<=value.
|
| __len__(self)
|
| __lt__(self, other)
| Return self<value.
|
| __mul__(self, n)
|
| __radd__(self, other)
|
| __repr__(self)
| Return repr(self).
|
| __rmul__ = __mul__(self, n)
|
| __setitem__(self, i, item)
|
| append(self, item)
| S.append(value) -- append value to the end of the sequence
|
| clear(self)
| S.clear() -> None -- remove all items from S
|
| copy(self)
|
| count(self, item)
| S.count(value) -> integer -- return number of occurrences of value
|
| extend(self, other)
| S.extend(iterable) -- extend sequence by appending elements from the iterable
|
| index(self, item, *args)
| S.index(value, [start, [stop]]) -> integer -- return first index of value.
| Raises ValueError if the value is not present.
|
| Supporting start and stop arguments is optional, but
| recommended.
|
| insert(self, i, item)
| S.insert(index, value) -- insert value before index
|
| pop(self, i=-1)
| S.pop([index]) -> item -- remove and return item at index (default last).
| Raise IndexError if list is empty or index is out of range.
|
| remove(self, item)
| S.remove(value) -- remove first occurrence of value.
| Raise ValueError if the value is not present.
|
| reverse(self)
| S.reverse() -- reverse *IN PLACE*
|
| sort(self, /, *args, **kwds)
|
| ----------------------------------------------------------------------
| Data descriptors defined here:
|
| __dict__
| dictionary for instance variables
|
| __weakref__
| list of weak references to the object
|
| ----------------------------------------------------------------------
| Data and other attributes defined here:
|
| __abstractmethods__ = frozenset()
|
| __hash__ = None
|
| ----------------------------------------------------------------------
| Methods inherited from collections.abc.Sequence:
|
| __iter__(self)
|
| __reversed__(self)
|
| ----------------------------------------------------------------------
| Class methods inherited from collections.abc.Reversible:
|
| __subclasshook__(C)
| Abstract classes can override this to customize issubclass().
|
| This is invoked early on by abc.ABCMeta.__subclasscheck__().
| It should return True, False or NotImplemented. If it returns
| NotImplemented, the normal algorithm is used. Otherwise, it
| overrides the normal algorithm (and the outcome is cached).
|
| ----------------------------------------------------------------------
| Class methods inherited from collections.abc.Iterable:
|
| __class_getitem__ = GenericAlias(...)
| Represent a PEP 585 generic type
|
| E.g. for t = list[int], t.__origin__ is list and t.__args__ is (int,).
class UserString(collections.abc.Sequence)
| UserString(seq)
|
| Method resolution order:
| UserString
| collections.abc.Sequence
| collections.abc.Reversible
| collections.abc.Collection
| collections.abc.Sized
| collections.abc.Iterable
| collections.abc.Container
| builtins.object
|
| Methods defined here:
|
| __add__(self, other)
|
| __complex__(self)
|
| __contains__(self, char)
|
| __eq__(self, string)
| Return self==value.
|
| __float__(self)
|
| __ge__(self, string)
| Return self>=value.
|
| __getitem__(self, index)
|
| __getnewargs__(self)
|
| __gt__(self, string)
| Return self>value.
|
| __hash__(self)
| Return hash(self).
|
| __init__(self, seq)
| Initialize self. See help(type(self)) for accurate signature.
|
| __int__(self)
|
| __le__(self, string)
| Return self<=value.
|
| __len__(self)
|
| __lt__(self, string)
| Return self<value.
|
| __mod__(self, args)
|
| __mul__(self, n)
|
| __radd__(self, other)
|
| __repr__(self)
| Return repr(self).
|
| __rmod__(self, template)
|
| __rmul__ = __mul__(self, n)
|
| __str__(self)
| Return str(self).
|
| capitalize(self)
| # the following methods are defined in alphabetical order:
|
| casefold(self)
|
| center(self, width, *args)
|
| count(self, sub, start=0, end=9223372036854775807)
| S.count(value) -> integer -- return number of occurrences of value
|
| encode(self, encoding='utf-8', errors='strict')
|
| endswith(self, suffix, start=0, end=9223372036854775807)
|
| expandtabs(self, tabsize=8)
|
| find(self, sub, start=0, end=9223372036854775807)
|
| format(self, /, *args, **kwds)
|
| format_map(self, mapping)
|
| index(self, sub, start=0, end=9223372036854775807)
| S.index(value, [start, [stop]]) -> integer -- return first index of value.
| Raises ValueError if the value is not present.
|
| Supporting start and stop arguments is optional, but
| recommended.
|
| isalnum(self)
|
| isalpha(self)
|
| isascii(self)
|
| isdecimal(self)
|
| isdigit(self)
|
| isidentifier(self)
|
| islower(self)
|
| isnumeric(self)
|
| isprintable(self)
|
| isspace(self)
|
| istitle(self)
|
| isupper(self)
|
| join(self, seq)
|
| ljust(self, width, *args)
|
| lower(self)
|
| lstrip(self, chars=None)
|
| partition(self, sep)
|
| removeprefix(self, prefix, /)
|
| removesuffix(self, suffix, /)
|
| replace(self, old, new, maxsplit=-1)
|
| rfind(self, sub, start=0, end=9223372036854775807)
|
| rindex(self, sub, start=0, end=9223372036854775807)
|
| rjust(self, width, *args)
|
| rpartition(self, sep)
|
| rsplit(self, sep=None, maxsplit=-1)
|
| rstrip(self, chars=None)
|
| split(self, sep=None, maxsplit=-1)
|
| splitlines(self, keepends=False)
|
| startswith(self, prefix, start=0, end=9223372036854775807)
|
| strip(self, chars=None)
|
| swapcase(self)
|
| title(self)
|
| translate(self, *args)
|
| upper(self)
|
| zfill(self, width)
|
| ----------------------------------------------------------------------
| Static methods defined here:
|
| maketrans(...)
| Return a translation table usable for str.translate().
|
| If there is only one argument, it must be a dictionary mapping Unicode
| ordinals (integers) or characters to Unicode ordinals, strings or None.
| Character keys will be then converted to ordinals.
| If there are two arguments, they must be strings of equal length, and
| in the resulting dictionary, each character in x will be mapped to the
| character at the same position in y. If there is a third argument, it
| must be a string, whose characters will be mapped to None in the result.
|
| ----------------------------------------------------------------------
| Data descriptors defined here:
|
| __dict__
| dictionary for instance variables
|
| __weakref__
| list of weak references to the object
|
| ----------------------------------------------------------------------
| Data and other attributes defined here:
|
| __abstractmethods__ = frozenset()
|
| ----------------------------------------------------------------------
| Methods inherited from collections.abc.Sequence:
|
| __iter__(self)
|
| __reversed__(self)
|
| ----------------------------------------------------------------------
| Class methods inherited from collections.abc.Reversible:
|
| __subclasshook__(C)
| Abstract classes can override this to customize issubclass().
|
| This is invoked early on by abc.ABCMeta.__subclasscheck__().
| It should return True, False or NotImplemented. If it returns
| NotImplemented, the normal algorithm is used. Otherwise, it
| overrides the normal algorithm (and the outcome is cached).
|
| ----------------------------------------------------------------------
| Class methods inherited from collections.abc.Iterable:
|
| __class_getitem__ = GenericAlias(...)
| Represent a PEP 585 generic type
|
| E.g. for t = list[int], t.__origin__ is list and t.__args__ is (int,).
class defaultdict(builtins.dict)
| defaultdict(default_factory=None, /, [...]) --> dict with default factory
|
| The default factory is called without arguments to produce
| a new value when a key is not present, in __getitem__ only.
| A defaultdict compares equal to a dict with the same items.
| All remaining arguments are treated the same as if they were
| passed to the dict constructor, including keyword arguments.
|
| Method resolution order:
| defaultdict
| builtins.dict
| builtins.object
|
| Methods defined here:
|
| __copy__(...)
| D.copy() -> a shallow copy of D.
|
| __getattribute__(self, name, /)
| Return getattr(self, name).
|
| __init__(self, /, *args, **kwargs)
| Initialize self. See help(type(self)) for accurate signature.
|
| __missing__(...)
| __missing__(key) # Called by __getitem__ for missing key; pseudo-code:
| if self.default_factory is None: raise KeyError((key,))
| self[key] = value = self.default_factory()
| return value
|
| __or__(self, value, /)
| Return self|value.
|
| __reduce__(...)
| Return state information for pickling.
|
| __repr__(self, /)
| Return repr(self).
|
| __ror__(self, value, /)
| Return value|self.
|
| copy(...)
| D.copy() -> a shallow copy of D.
|
| ----------------------------------------------------------------------
| Class methods defined here:
|
| __class_getitem__(...)
| See PEP 585
|
| ----------------------------------------------------------------------
| Data descriptors defined here:
|
| default_factory
| Factory for default value called by __missing__().
|
| ----------------------------------------------------------------------
| Methods inherited from builtins.dict:
|
| __contains__(self, key, /)
| True if the dictionary has the specified key, else False.
|
| __delitem__(self, key, /)
| Delete self[key].
|
| __eq__(self, value, /)
| Return self==value.
|
| __ge__(self, value, /)
| Return self>=value.
|
| __getitem__(self, key, /)
| Return self[key].
|
| __gt__(self, value, /)
| Return self>value.
|
| __ior__(self, value, /)
| Return self|=value.
|
| __iter__(self, /)
| Implement iter(self).
|
| __le__(self, value, /)
| Return self<=value.
|
| __len__(self, /)
| Return len(self).
|
| __lt__(self, value, /)
| Return self<value.
|
| __ne__(self, value, /)
| Return self!=value.
|
| __reversed__(self, /)
| Return a reverse iterator over the dict keys.
|
| __setitem__(self, key, value, /)
| Set self[key] to value.
|
| __sizeof__(...)
| D.__sizeof__() -> size of D in memory, in bytes
|
| clear(...)
| D.clear() -> None. Remove all items from D.
|
| get(self, key, default=None, /)
| Return the value for key if key is in the dictionary, else default.
|
| items(...)
| D.items() -> a set-like object providing a view on D's items
|
| keys(...)
| D.keys() -> a set-like object providing a view on D's keys
|
| pop(...)
| D.pop(k[,d]) -> v, remove specified key and return the corresponding value.
|
| If the key is not found, return the default if given; otherwise,
| raise a KeyError.
|
| popitem(self, /)
| Remove and return a (key, value) pair as a 2-tuple.
|
| Pairs are returned in LIFO (last-in, first-out) order.
| Raises KeyError if the dict is empty.
|
| setdefault(self, key, default=None, /)
| Insert key with a value of default if key is not in the dictionary.
|
| Return the value for key if key is in the dictionary, else default.
|
| update(...)
| D.update([E, ]**F) -> None. Update D from dict/iterable E and F.
| If E is present and has a .keys() method, then does: for k in E: D[k] = E[k]
| If E is present and lacks a .keys() method, then does: for k, v in E: D[k] = v
| In either case, this is followed by: for k in F: D[k] = F[k]
|
| values(...)
| D.values() -> an object providing a view on D's values
|
| ----------------------------------------------------------------------
| Class methods inherited from builtins.dict:
|
| fromkeys(iterable, value=None, /)
| Create a new dictionary with keys from iterable and values set to value.
|
| ----------------------------------------------------------------------
| Static methods inherited from builtins.dict:
|
| __new__(*args, **kwargs) class method of builtins.dict
| Create and return a new object. See help(type) for accurate signature.
|
| ----------------------------------------------------------------------
| Data and other attributes inherited from builtins.dict:
|
| __hash__ = None
class deque(builtins.object)
| deque([iterable[, maxlen]]) --> deque object
|
| A list-like sequence optimized for data accesses near its endpoints.
|
| Methods defined here:
|
| __add__(self, value, /)
| Return self+value.
|
| __contains__(self, key, /)
| Return bool(key in self).
|
| __copy__(...)
| Return a shallow copy of a deque.
|
| __delitem__(self, key, /)
| Delete self[key].
|
| __eq__(self, value, /)
| Return self==value.
|
| __ge__(self, value, /)
| Return self>=value.
|
| __getattribute__(self, name, /)
| Return getattr(self, name).
|
| __getitem__(self, key, /)
| Return self[key].
|
| __gt__(self, value, /)
| Return self>value.
|
| __iadd__(self, value, /)
| Implement self+=value.
|
| __imul__(self, value, /)
| Implement self*=value.
|
| __init__(self, /, *args, **kwargs)
| Initialize self. See help(type(self)) for accurate signature.
|
| __iter__(self, /)
| Implement iter(self).
|
| __le__(self, value, /)
| Return self<=value.
|
| __len__(self, /)
| Return len(self).
|
| __lt__(self, value, /)
| Return self<value.
|
| __mul__(self, value, /)
| Return self*value.
|
| __ne__(self, value, /)
| Return self!=value.
|
| __reduce__(...)
| Return state information for pickling.
|
| __repr__(self, /)
| Return repr(self).
|
| __reversed__(...)
| D.__reversed__() -- return a reverse iterator over the deque
|
| __rmul__(self, value, /)
| Return value*self.
|
| __setitem__(self, key, value, /)
| Set self[key] to value.
|
| __sizeof__(...)
| D.__sizeof__() -- size of D in memory, in bytes
|
| append(...)
| Add an element to the right side of the deque.
|
| appendleft(...)
| Add an element to the left side of the deque.
|
| clear(...)
| Remove all elements from the deque.
|
| copy(...)
| Return a shallow copy of a deque.
|
| count(...)
| D.count(value) -- return number of occurrences of value
|
| extend(...)
| Extend the right side of the deque with elements from the iterable
|
| extendleft(...)
| Extend the left side of the deque with elements from the iterable
|
| index(...)
| D.index(value, [start, [stop]]) -- return first index of value.
| Raises ValueError if the value is not present.
|
| insert(...)
| D.insert(index, object) -- insert object before index
|
| pop(...)
| Remove and return the rightmost element.
|
| popleft(...)
| Remove and return the leftmost element.
|
| remove(...)
| D.remove(value) -- remove first occurrence of value.
|
| reverse(...)
| D.reverse() -- reverse *IN PLACE*
|
| rotate(...)
| Rotate the deque n steps to the right (default n=1). If n is negative, rotates left.
|
| ----------------------------------------------------------------------
| 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:
|
| maxlen
| maximum size of a deque or None if unbounded
|
| ----------------------------------------------------------------------
| Data and other attributes defined here:
|
| __hash__ = None
FUNCTIONS
namedtuple(typename, field_names, *, rename=False, defaults=None, module=None)
Returns a new subclass of tuple with named fields.
>>> Point = namedtuple('Point', ['x', 'y'])
>>> Point.__doc__ # docstring for the new class
'Point(x, y)'
>>> p = Point(11, y=22) # instantiate with positional args or keywords
>>> p[0] + p[1] # indexable like a plain tuple
33
>>> x, y = p # unpack like a regular tuple
>>> x, y
(11, 22)
>>> p.x + p.y # fields also accessible by name
33
>>> d = p._asdict() # convert to a dictionary
>>> d['x']
11
>>> Point(**d) # convert from a dictionary
Point(x=11, y=22)
>>> p._replace(x=100) # _replace() is like str.replace() but targets named fields
Point(x=100, y=22)
DATA
__all__ = ['ChainMap', 'Counter', 'OrderedDict', 'UserDict', 'UserList...
FILE
c:\users\youse\appdata\local\programs\python\python312\lib\collections\__init__.py
traceback.extract_stack
Python Library Documentation: function extract_stack in module traceback
extract_stack(f=None, limit=None)
Extract the raw traceback from the current stack frame.
The return value has the same format as for extract_tb(). The
optional 'f' and 'limit' arguments have the same meaning as for
print_stack(). Each item in the list is a quadruple (filename,
line number, function name, text), and the entries are in order
from oldest to newest stack frame.
traceback.extract_tb
Python Library Documentation: function extract_tb in module traceback
extract_tb(tb, limit=None)
Return a StackSummary object representing a list of
pre-processed entries from traceback.
This is useful for alternate formatting of stack traces. If
'limit' is omitted or None, all entries are extracted. A
pre-processed stack trace entry is a FrameSummary object
containing attributes filename, lineno, name, and line
representing the information that is usually printed for a stack
trace. The line is a string with leading and trailing
whitespace stripped; if the source is not available it is None.
traceback.format_exc
Python Library Documentation: function format_exc in module traceback
format_exc(limit=None, chain=True)
Like print_exc() but return a string.
traceback.format_exception
Python Library Documentation: function format_exception in module traceback
format_exception(exc, /, value=<implicit>, tb=<implicit>, limit=None, chain=True)
Format a stack trace and the exception information.
The arguments have the same meaning as the corresponding arguments
to print_exception(). The return value is a list of strings, each
ending in a newline and some containing internal newlines. When
these lines are concatenated and printed, exactly the same text is
printed as does print_exception().
traceback.format_exception_only
Python Library Documentation: function format_exception_only in module traceback
format_exception_only(exc, /, value=<implicit>)
Format the exception part of a traceback.
The return value is a list of strings, each ending in a newline.
The list contains the exception's message, which is
normally a single string; however, for :exc:`SyntaxError` exceptions, it
contains several lines that (when printed) display detailed information
about where the syntax error occurred. Following the message, the list
contains the exception's ``__notes__``.
traceback.format_list
Python Library Documentation: function format_list in module traceback
format_list(extracted_list)
Format a list of tuples or FrameSummary objects for printing.
Given a list of tuples or FrameSummary objects as returned by
extract_tb() or extract_stack(), return a list of strings ready
for printing.
Each string in the resulting list corresponds to the item with the
same index in the argument list. Each string ends in a newline;
the strings may contain internal newlines as well, for those items
whose source text line is not None.
traceback.format_stack
Python Library Documentation: function format_stack in module traceback
format_stack(f=None, limit=None)
Shorthand for 'format_list(extract_stack(f, limit))'.
traceback.format_tb
Python Library Documentation: function format_tb in module traceback
format_tb(tb, limit=None)
A shorthand for 'format_list(extract_tb(tb, limit))'.
traceback.itertools
Python Library Documentation: built-in module itertools
NAME
itertools - Functional tools for creating and using iterators.
DESCRIPTION
Infinite iterators:
count(start=0, step=1) --> start, start+step, start+2*step, ...
cycle(p) --> p0, p1, ... plast, p0, p1, ...
repeat(elem [,n]) --> elem, elem, elem, ... endlessly or up to n times
Iterators terminating on the shortest input sequence:
accumulate(p[, func]) --> p0, p0+p1, p0+p1+p2
batched(p, n) --> [p0, p1, ..., p_n-1], [p_n, p_n+1, ..., p_2n-1], ...
chain(p, q, ...) --> p0, p1, ... plast, q0, q1, ...
chain.from_iterable([p, q, ...]) --> p0, p1, ... plast, q0, q1, ...
compress(data, selectors) --> (d[0] if s[0]), (d[1] if s[1]), ...
dropwhile(predicate, seq) --> seq[n], seq[n+1], starting when predicate fails
groupby(iterable[, keyfunc]) --> sub-iterators grouped by value of keyfunc(v)
filterfalse(predicate, seq) --> elements of seq where predicate(elem) is False
islice(seq, [start,] stop [, step]) --> elements from
seq[start:stop:step]
pairwise(s) --> (s[0],s[1]), (s[1],s[2]), (s[2], s[3]), ...
starmap(fun, seq) --> fun(*seq[0]), fun(*seq[1]), ...
tee(it, n=2) --> (it1, it2 , ... itn) splits one iterator into n
takewhile(predicate, seq) --> seq[0], seq[1], until predicate fails
zip_longest(p, q, ...) --> (p[0], q[0]), (p[1], q[1]), ...
Combinatoric generators:
product(p, q, ... [repeat=1]) --> cartesian product
permutations(p[, r])
combinations(p, r)
combinations_with_replacement(p, r)
CLASSES
builtins.object
accumulate
batched
chain
combinations
combinations_with_replacement
compress
count
cycle
dropwhile
filterfalse
groupby
islice
pairwise
permutations
product
repeat
starmap
takewhile
zip_longest
class accumulate(builtins.object)
| accumulate(iterable, func=None, *, initial=None)
|
| Return series of accumulated sums (or other binary function results).
|
| Methods defined here:
|
| __getattribute__(self, name, /)
| Return getattr(self, name).
|
| __iter__(self, /)
| Implement iter(self).
|
| __next__(self, /)
| Implement next(self).
|
| __reduce__(...)
| Return state information for pickling.
|
| __setstate__(...)
| Set state information for unpickling.
|
| ----------------------------------------------------------------------
| Static methods defined here:
|
| __new__(*args, **kwargs)
| Create and return a new object. See help(type) for accurate signature.
class batched(builtins.object)
| batched(iterable, n)
|
| Batch data into tuples of length n. The last batch may be shorter than n.
|
| Loops over the input iterable and accumulates data into tuples
| up to size n. The input is consumed lazily, just enough to
| fill a batch. The result is yielded as soon as a batch is full
| or when the input iterable is exhausted.
|
| >>> for batch in batched('ABCDEFG', 3):
| ... print(batch)
| ...
| ('A', 'B', 'C')
| ('D', 'E', 'F')
| ('G',)
|
| Methods defined here:
|
| __getattribute__(self, name, /)
| Return getattr(self, name).
|
| __iter__(self, /)
| Implement iter(self).
|
| __next__(self, /)
| Implement next(self).
|
| ----------------------------------------------------------------------
| Static methods defined here:
|
| __new__(*args, **kwargs)
| Create and return a new object. See help(type) for accurate signature.
class chain(builtins.object)
| chain(*iterables) --> chain object
|
| Return a chain object whose .__next__() method returns elements from the
| first iterable until it is exhausted, then elements from the next
| iterable, until all of the iterables are exhausted.
|
| Methods defined here:
|
| __getattribute__(self, name, /)
| Return getattr(self, name).
|
| __iter__(self, /)
| Implement iter(self).
|
| __next__(self, /)
| Implement next(self).
|
| __reduce__(...)
| Return state information for pickling.
|
| __setstate__(...)
| Set state information for unpickling.
|
| ----------------------------------------------------------------------
| Class methods defined here:
|
| __class_getitem__(...)
| See PEP 585
|
| from_iterable(iterable, /)
| Alternative chain() constructor taking a single iterable argument that evaluates lazily.
|
| ----------------------------------------------------------------------
| Static methods defined here:
|
| __new__(*args, **kwargs)
| Create and return a new object. See help(type) for accurate signature.
class combinations(builtins.object)
| combinations(iterable, r)
|
| Return successive r-length combinations of elements in the iterable.
|
| combinations(range(4), 3) --> (0,1,2), (0,1,3), (0,2,3), (1,2,3)
|
| Methods defined here:
|
| __getattribute__(self, name, /)
| Return getattr(self, name).
|
| __iter__(self, /)
| Implement iter(self).
|
| __next__(self, /)
| Implement next(self).
|
| __reduce__(...)
| Return state information for pickling.
|
| __setstate__(...)
| Set state information for unpickling.
|
| __sizeof__(...)
| Returns size in memory, in bytes.
|
| ----------------------------------------------------------------------
| Static methods defined here:
|
| __new__(*args, **kwargs)
| Create and return a new object. See help(type) for accurate signature.
class combinations_with_replacement(builtins.object)
| combinations_with_replacement(iterable, r)
|
| Return successive r-length combinations of elements in the iterable allowing individual elements to have successive repeats.
|
| combinations_with_replacement('ABC', 2) --> ('A','A'), ('A','B'), ('A','C'), ('B','B'), ('B','C'), ('C','C')
|
| Methods defined here:
|
| __getattribute__(self, name, /)
| Return getattr(self, name).
|
| __iter__(self, /)
| Implement iter(self).
|
| __next__(self, /)
| Implement next(self).
|
| __reduce__(...)
| Return state information for pickling.
|
| __setstate__(...)
| Set state information for unpickling.
|
| __sizeof__(...)
| Returns size in memory, in bytes.
|
| ----------------------------------------------------------------------
| Static methods defined here:
|
| __new__(*args, **kwargs)
| Create and return a new object. See help(type) for accurate signature.
class compress(builtins.object)
| compress(data, selectors)
|
| Return data elements corresponding to true selector elements.
|
| Forms a shorter iterator from selected data elements using the selectors to
| choose the data elements.
|
| Methods defined here:
|
| __getattribute__(self, name, /)
| Return getattr(self, name).
|
| __iter__(self, /)
| Implement iter(self).
|
| __next__(self, /)
| Implement next(self).
|
| __reduce__(...)
| Return state information for pickling.
|
| ----------------------------------------------------------------------
| Static methods defined here:
|
| __new__(*args, **kwargs)
| Create and return a new object. See help(type) for accurate signature.
class count(builtins.object)
| count(start=0, step=1)
|
| Return a count object whose .__next__() method returns consecutive values.
|
| Equivalent to:
| def count(firstval=0, step=1):
| x = firstval
| while 1:
| yield x
| x += step
|
| Methods defined here:
|
| __getattribute__(self, name, /)
| Return getattr(self, name).
|
| __iter__(self, /)
| Implement iter(self).
|
| __next__(self, /)
| Implement next(self).
|
| __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.
class cycle(builtins.object)
| cycle(iterable, /)
|
| Return elements from the iterable until it is exhausted. Then repeat the sequence indefinitely.
|
| Methods defined here:
|
| __getattribute__(self, name, /)
| Return getattr(self, name).
|
| __iter__(self, /)
| Implement iter(self).
|
| __next__(self, /)
| Implement next(self).
|
| __reduce__(...)
| Return state information for pickling.
|
| __setstate__(...)
| Set state information for unpickling.
|
| ----------------------------------------------------------------------
| Static methods defined here:
|
| __new__(*args, **kwargs)
| Create and return a new object. See help(type) for accurate signature.
class dropwhile(builtins.object)
| dropwhile(predicate, iterable, /)
|
| Drop items from the iterable while predicate(item) is true.
|
| Afterwards, return every element until the iterable is exhausted.
|
| Methods defined here:
|
| __getattribute__(self, name, /)
| Return getattr(self, name).
|
| __iter__(self, /)
| Implement iter(self).
|
| __next__(self, /)
| Implement next(self).
|
| __reduce__(...)
| Return state information for pickling.
|
| __setstate__(...)
| Set state information for unpickling.
|
| ----------------------------------------------------------------------
| Static methods defined here:
|
| __new__(*args, **kwargs)
| Create and return a new object. See help(type) for accurate signature.
class filterfalse(builtins.object)
| filterfalse(function, iterable, /)
|
| Return those items of iterable for which function(item) is false.
|
| If function is None, return the items that are false.
|
| Methods defined here:
|
| __getattribute__(self, name, /)
| Return getattr(self, name).
|
| __iter__(self, /)
| Implement iter(self).
|
| __next__(self, /)
| Implement next(self).
|
| __reduce__(...)
| Return state information for pickling.
|
| ----------------------------------------------------------------------
| Static methods defined here:
|
| __new__(*args, **kwargs)
| Create and return a new object. See help(type) for accurate signature.
class groupby(builtins.object)
| groupby(iterable, key=None)
|
| make an iterator that returns consecutive keys and groups from the iterable
|
| iterable
| Elements to divide into groups according to the key function.
| key
| A function for computing the group category for each element.
| If the key function is not specified or is None, the element itself
| is used for grouping.
|
| Methods defined here:
|
| __getattribute__(self, name, /)
| Return getattr(self, name).
|
| __iter__(self, /)
| Implement iter(self).
|
| __next__(self, /)
| Implement next(self).
|
| __reduce__(...)
| Return state information for pickling.
|
| __setstate__(...)
| Set state information for unpickling.
|
| ----------------------------------------------------------------------
| Static methods defined here:
|
| __new__(*args, **kwargs)
| Create and return a new object. See help(type) for accurate signature.
class islice(builtins.object)
| islice(iterable, stop) --> islice object
| islice(iterable, start, stop[, step]) --> islice object
|
| Return an iterator whose next() method returns selected values from an
| iterable. If start is specified, will skip all preceding elements;
| otherwise, start defaults to zero. Step defaults to one. If
| specified as another value, step determines how many values are
| skipped between successive calls. Works like a slice() on a list
| but returns an iterator.
|
| Methods defined here:
|
| __getattribute__(self, name, /)
| Return getattr(self, name).
|
| __iter__(self, /)
| Implement iter(self).
|
| __next__(self, /)
| Implement next(self).
|
| __reduce__(...)
| Return state information for pickling.
|
| __setstate__(...)
| Set state information for unpickling.
|
| ----------------------------------------------------------------------
| Static methods defined here:
|
| __new__(*args, **kwargs)
| Create and return a new object. See help(type) for accurate signature.
class pairwise(builtins.object)
| pairwise(iterable, /)
|
| Return an iterator of overlapping pairs taken from the input iterator.
|
| s -> (s0,s1), (s1,s2), (s2, s3), ...
|
| Methods defined here:
|
| __getattribute__(self, name, /)
| Return getattr(self, name).
|
| __iter__(self, /)
| Implement iter(self).
|
| __next__(self, /)
| Implement next(self).
|
| ----------------------------------------------------------------------
| Static methods defined here:
|
| __new__(*args, **kwargs)
| Create and return a new object. See help(type) for accurate signature.
class permutations(builtins.object)
| permutations(iterable, r=None)
|
| Return successive r-length permutations of elements in the iterable.
|
| permutations(range(3), 2) --> (0,1), (0,2), (1,0), (1,2), (2,0), (2,1)
|
| Methods defined here:
|
| __getattribute__(self, name, /)
| Return getattr(self, name).
|
| __iter__(self, /)
| Implement iter(self).
|
| __next__(self, /)
| Implement next(self).
|
| __reduce__(...)
| Return state information for pickling.
|
| __setstate__(...)
| Set state information for unpickling.
|
| __sizeof__(...)
| Returns size in memory, in bytes.
|
| ----------------------------------------------------------------------
| Static methods defined here:
|
| __new__(*args, **kwargs)
| Create and return a new object. See help(type) for accurate signature.
class product(builtins.object)
| product(*iterables, repeat=1) --> product object
|
| Cartesian product of input iterables. Equivalent to nested for-loops.
|
| For example, product(A, B) returns the same as: ((x,y) for x in A for y in B).
| The leftmost iterators are in the outermost for-loop, so the output tuples
| cycle in a manner similar to an odometer (with the rightmost element changing
| on every iteration).
|
| To compute the product of an iterable with itself, specify the number
| of repetitions with the optional repeat keyword argument. For example,
| product(A, repeat=4) means the same as product(A, A, A, A).
|
| product('ab', range(3)) --> ('a',0) ('a',1) ('a',2) ('b',0) ('b',1) ('b',2)
| product((0,1), (0,1), (0,1)) --> (0,0,0) (0,0,1) (0,1,0) (0,1,1) (1,0,0) ...
|
| Methods defined here:
|
| __getattribute__(self, name, /)
| Return getattr(self, name).
|
| __iter__(self, /)
| Implement iter(self).
|
| __next__(self, /)
| Implement next(self).
|
| __reduce__(...)
| Return state information for pickling.
|
| __setstate__(...)
| Set state information for unpickling.
|
| __sizeof__(...)
| Returns size in memory, in bytes.
|
| ----------------------------------------------------------------------
| Static methods defined here:
|
| __new__(*args, **kwargs)
| Create and return a new object. See help(type) for accurate signature.
class repeat(builtins.object)
| repeat(object [,times]) -> create an iterator which returns the object
| for the specified number of times. If not specified, returns the object
| endlessly.
|
| Methods defined here:
|
| __getattribute__(self, name, /)
| Return getattr(self, name).
|
| __iter__(self, /)
| Implement iter(self).
|
| __length_hint__(...)
| Private method returning an estimate of len(list(it)).
|
| __next__(self, /)
| Implement next(self).
|
| __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.
class starmap(builtins.object)
| starmap(function, iterable, /)
|
| Return an iterator whose values are returned from the function evaluated with an argument tuple taken from the given sequence.
|
| Methods defined here:
|
| __getattribute__(self, name, /)
| Return getattr(self, name).
|
| __iter__(self, /)
| Implement iter(self).
|
| __next__(self, /)
| Implement next(self).
|
| __reduce__(...)
| Return state information for pickling.
|
| ----------------------------------------------------------------------
| Static methods defined here:
|
| __new__(*args, **kwargs)
| Create and return a new object. See help(type) for accurate signature.
class takewhile(builtins.object)
| takewhile(predicate, iterable, /)
|
| Return successive entries from an iterable as long as the predicate evaluates to true for each entry.
|
| Methods defined here:
|
| __getattribute__(self, name, /)
| Return getattr(self, name).
|
| __iter__(self, /)
| Implement iter(self).
|
| __next__(self, /)
| Implement next(self).
|
| __reduce__(...)
| Return state information for pickling.
|
| __setstate__(...)
| Set state information for unpickling.
|
| ----------------------------------------------------------------------
| Static methods defined here:
|
| __new__(*args, **kwargs)
| Create and return a new object. See help(type) for accurate signature.
class zip_longest(builtins.object)
| zip_longest(iter1 [,iter2 [...]], [fillvalue=None]) --> zip_longest object
|
| Return a zip_longest object whose .__next__() method returns a tuple where
| the i-th element comes from the i-th iterable argument. The .__next__()
| method continues until the longest iterable in the argument sequence
| is exhausted and then it raises StopIteration. When the shorter iterables
| are exhausted, the fillvalue is substituted in their place. The fillvalue
| defaults to None or can be specified by a keyword argument.
|
| Methods defined here:
|
| __getattribute__(self, name, /)
| Return getattr(self, name).
|
| __iter__(self, /)
| Implement iter(self).
|
| __next__(self, /)
| Implement next(self).
|
| __reduce__(...)
| Return state information for pickling.
|
| __setstate__(...)
| Set state information for unpickling.
|
| ----------------------------------------------------------------------
| Static methods defined here:
|
| __new__(*args, **kwargs)
| Create and return a new object. See help(type) for accurate signature.
FUNCTIONS
tee(iterable, n=2, /)
Returns a tuple of n independent iterators.
FILE
(built-in)
traceback.linecache
Python Library Documentation: module linecache
NAME
linecache - Cache lines from Python source files.
MODULE REFERENCE
https://docs.python.org/3.12/library/linecache.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 is intended to read lines from modules imported -- hence if a filename
is not found, it will look down the module search path for a file by
that name.
FUNCTIONS
checkcache(filename=None)
Discard cache entries that are out of date.
(This is not checked upon each call!)
clearcache()
Clear the cache entirely.
getline(filename, lineno, module_globals=None)
Get a line for a Python source file from the cache.
Update the cache if it doesn't contain an entry for this file already.
lazycache(filename, module_globals)
Seed the cache for filename with module_globals.
The module loader will be asked for the source only when getlines is
called, not immediately.
If there is an entry in the cache already, it is not altered.
:return: True if a lazy load is registered in the cache,
otherwise False. To register such a load a module loader with a
get_source method must be found, the filename must be a cacheable
filename, and the filename must not be already cached.
DATA
__all__ = ['getline', 'clearcache', 'checkcache', 'lazycache']
FILE
c:\users\youse\appdata\local\programs\python\python312\lib\linecache.py
traceback.print_exc
Python Library Documentation: function print_exc in module traceback
print_exc(limit=None, file=None, chain=True)
Shorthand for 'print_exception(sys.exception(), limit, file, chain)'.
traceback.print_exception
Python Library Documentation: function print_exception in module traceback
print_exception(exc, /, value=<implicit>, tb=<implicit>, limit=None, file=None, chain=True)
Print exception up to 'limit' stack trace entries from 'tb' to 'file'.
This differs from print_tb() in the following ways: (1) if
traceback is not None, it prints a header "Traceback (most recent
call last):"; (2) it prints the exception type and value after the
stack trace; (3) if type is SyntaxError and value has the
appropriate format, it prints the line where the syntax error
occurred with a caret on the next line indicating the approximate
position of the error.
traceback.print_last
Python Library Documentation: function print_last in module traceback
print_last(limit=None, file=None, chain=True)
This is a shorthand for 'print_exception(sys.last_exc, limit, file, chain)'.
traceback.print_list
Python Library Documentation: function print_list in module traceback
print_list(extracted_list, file=None)
Print the list of tuples as returned by extract_tb() or
extract_stack() as a formatted stack trace to the given file.
traceback.print_stack
Python Library Documentation: function print_stack in module traceback
print_stack(f=None, limit=None, file=None)
Print a stack trace from its invocation point.
The optional 'f' argument can be used to specify an alternate
stack frame at which to start. The optional 'limit' and 'file'
arguments have the same meaning as for print_exception().
traceback.print_tb
Python Library Documentation: function print_tb in module traceback
print_tb(tb, limit=None, file=None)
Print up to 'limit' stack trace entries from the traceback 'tb'.
If 'limit' is omitted or None, all entries are printed. If 'file'
is omitted or None, the output goes to sys.stderr; otherwise
'file' should be an open file or file-like object with a write()
method.
traceback.suppress
Python Library Documentation: class suppress in module contextlib class suppress(AbstractContextManager) | suppress(*exceptions) | | Context manager to suppress specified exceptions | | After the exception is suppressed, execution proceeds with the next | statement following the with statement. | | with suppress(FileNotFoundError): | os.remove(somefile) | # Execution still resumes here if the file was already removed | | Method resolution order: | suppress | AbstractContextManager | abc.ABC | builtins.object | | Methods defined here: | | __enter__(self) | Return `self` upon entering the runtime context. | | __exit__(self, exctype, excinst, exctb) | Raise any exception triggered within the runtime context. | | __init__(self, *exceptions) | Initialize self. See help(type(self)) for accurate signature. | | ---------------------------------------------------------------------- | Data and other attributes defined here: | | __abstractmethods__ = frozenset() | | ---------------------------------------------------------------------- | Class methods inherited from AbstractContextManager: | | __class_getitem__ = GenericAlias(...) | Represent a PEP 585 generic type | | E.g. for t = list[int], t.__origin__ is list and t.__args__ is (int,). | | __subclasshook__(C) | Abstract classes can override this to customize issubclass(). | | This is invoked early on by abc.ABCMeta.__subclasscheck__(). | It should return True, False or NotImplemented. If it returns | NotImplemented, the normal algorithm is used. Otherwise, it | overrides the normal algorithm (and the outcome is cached). | | ---------------------------------------------------------------------- | Data descriptors inherited from AbstractContextManager: | | __dict__ | dictionary for instance variables | | __weakref__ | list of weak references to the object
traceback.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', 'traceback', 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)
traceback.textwrap
Python Library Documentation: module textwrap
NAME
textwrap - Text wrapping and filling.
MODULE REFERENCE
https://docs.python.org/3.12/library/textwrap.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
TextWrapper
class TextWrapper(builtins.object)
| TextWrapper(width=70, initial_indent='', subsequent_indent='', expand_tabs=True, replace_whitespace=True, fix_sentence_endings=False, break_long_words=True, drop_whitespace=True, break_on_hyphens=True, tabsize=8, *, max_lines=None, placeholder=' [...]')
|
| Object for wrapping/filling text. The public interface consists of
| the wrap() and fill() methods; the other methods are just there for
| subclasses to override in order to tweak the default behaviour.
| If you want to completely replace the main wrapping algorithm,
| you'll probably have to override _wrap_chunks().
|
| Several instance attributes control various aspects of wrapping:
| width (default: 70)
| the maximum width of wrapped lines (unless break_long_words
| is false)
| initial_indent (default: "")
| string that will be prepended to the first line of wrapped
| output. Counts towards the line's width.
| subsequent_indent (default: "")
| string that will be prepended to all lines save the first
| of wrapped output; also counts towards each line's width.
| expand_tabs (default: true)
| Expand tabs in input text to spaces before further processing.
| Each tab will become 0 .. 'tabsize' spaces, depending on its position
| in its line. If false, each tab is treated as a single character.
| tabsize (default: 8)
| Expand tabs in input text to 0 .. 'tabsize' spaces, unless
| 'expand_tabs' is false.
| replace_whitespace (default: true)
| Replace all whitespace characters in the input text by spaces
| after tab expansion. Note that if expand_tabs is false and
| replace_whitespace is true, every tab will be converted to a
| single space!
| fix_sentence_endings (default: false)
| Ensure that sentence-ending punctuation is always followed
| by two spaces. Off by default because the algorithm is
| (unavoidably) imperfect.
| break_long_words (default: true)
| Break words longer than 'width'. If false, those words will not
| be broken, and some lines might be longer than 'width'.
| break_on_hyphens (default: true)
| Allow breaking hyphenated words. If true, wrapping will occur
| preferably on whitespaces and right after hyphens part of
| compound words.
| drop_whitespace (default: true)
| Drop leading and trailing whitespace from lines.
| max_lines (default: None)
| Truncate wrapped lines.
| placeholder (default: ' [...]')
| Append to the last line of truncated text.
|
| Methods defined here:
|
| __init__(self, width=70, initial_indent='', subsequent_indent='', expand_tabs=True, replace_whitespace=True, fix_sentence_endings=False, break_long_words=True, drop_whitespace=True, break_on_hyphens=True, tabsize=8, *, max_lines=None, placeholder=' [...]')
| Initialize self. See help(type(self)) for accurate signature.
|
| fill(self, text)
| fill(text : string) -> string
|
| Reformat the single paragraph in 'text' to fit in lines of no
| more than 'self.width' columns, and return a new string
| containing the entire wrapped paragraph.
|
| wrap(self, text)
| wrap(text : string) -> [string]
|
| Reformat the single paragraph in 'text' so it fits in lines of
| no more than 'self.width' columns, and return a list of wrapped
| lines. Tabs in 'text' are expanded with string.expandtabs(),
| and all other whitespace characters (including newline) are
| converted to space.
|
| ----------------------------------------------------------------------
| Data descriptors defined here:
|
| __dict__
| dictionary for instance variables
|
| __weakref__
| list of weak references to the object
|
| ----------------------------------------------------------------------
| Data and other attributes defined here:
|
| sentence_end_re = re.compile('[a-z][\\.\\!\\?][\\"\\\']?\\Z')
|
| unicode_whitespace_trans = {9: 32, 10: 32, 11: 32, 12: 32, 13: 32, 32:...
|
| wordsep_re = re.compile('\n ( # any whitespace\n ...# word...
|
| wordsep_simple_re = re.compile('([\\\t\\\n\\\x0b\\\x0c\\\r\\ ]+)')
FUNCTIONS
dedent(text)
Remove any common leading whitespace from every line in `text`.
This can be used to make triple-quoted strings line up with the left
edge of the display, while still presenting them in the source code
in indented form.
Note that tabs and spaces are both treated as whitespace, but they
are not equal: the lines " hello" and "\thello" are
considered to have no common leading whitespace.
Entirely blank lines are normalized to a newline character.
fill(text, width=70, **kwargs)
Fill a single paragraph of text, returning a new string.
Reformat the single paragraph in 'text' to fit in lines of no more
than 'width' columns, and return a new string containing the entire
wrapped paragraph. As with wrap(), tabs are expanded and other
whitespace characters converted to space. See TextWrapper class for
available keyword args to customize wrapping behaviour.
indent(text, prefix, predicate=None)
Adds 'prefix' to the beginning of selected lines in 'text'.
If 'predicate' is provided, 'prefix' will only be added to the lines
where 'predicate(line)' is True. If 'predicate' is not provided,
it will default to adding 'prefix' to all non-empty lines that do not
consist solely of whitespace characters.
shorten(text, width, **kwargs)
Collapse and truncate the given text to fit in the given width.
The text first has its whitespace collapsed. If it then fits in
the *width*, it is returned as is. Otherwise, as many words
as possible are joined and then the placeholder is appended::
>>> textwrap.shorten("Hello world!", width=12)
'Hello world!'
>>> textwrap.shorten("Hello world!", width=11)
'Hello [...]'
wrap(text, width=70, **kwargs)
Wrap a single paragraph of text, returning a list of wrapped lines.
Reformat the single paragraph in 'text' so it fits in lines of no
more than 'width' columns, and return a list of wrapped lines. By
default, tabs in 'text' are expanded with string.expandtabs(), and
all other whitespace characters (including newline) are converted to
space. See TextWrapper class for available keyword args to customize
wrapping behaviour.
DATA
__all__ = ['TextWrapper', 'wrap', 'fill', 'dedent', 'indent', 'shorten...
FILE
c:\users\youse\appdata\local\programs\python\python312\lib\textwrap.py
traceback.walk_stack
Python Library Documentation: function walk_stack in module traceback
walk_stack(f)
Walk a stack yielding the frame and line number for each frame.
This will follow f.f_back from the given frame. If no frame is given, the
current stack is used. Usually used with StackSummary.extract.
traceback.walk_tb
Python Library Documentation: function walk_tb in module traceback
walk_tb(tb)
Walk a traceback yielding the frame and line number for each frame.
This will follow tb.tb_next (and thus is in the opposite order to
walk_stack). Usually used with StackSummary.extract.