Extending and Embedding Python, Release 3.9.5 >>> import email.mime.text >>> email.mime.text.__name__ 'email.mime.text' reference count The number of references to an object. When the reference count of an object drops to zero, it is deallocated. Reference counting is generally not visible to Python code, but it is a key element of the CPython implementation. The$_{sys}$ module defines a$_{getrefcount()}$ function that programmers can call to return the reference count for a particular object. __slots__ A declaration inside a class that saves memory by pre-declaring space for instance attributes and eliminat- ing instance dictionaries. Though popular, the technique is somewhat tricky to get right and is best reserved for rare cases where there are large numbers of instances in a memory-critical application. sequence An iterable which supports efficient element access using integer indices via the __getitem__() spe- cial method and defines a$_{__len__()}$ method that returns the length of the sequence. Some built-in se- quence types are list , str , tuple , and bytes . Note that dict also supports __getitem__() and __len__() , but is considered a mapping rather than a sequence because the lookups use arbitrary immutable keys rather than integers. set comprehension A compact way to process all or part of the elements in an iterable and return a set with the results. results = {c for c in 'abracadabra' if c not in 'abc'} generates the set of strings$_{{'r', 'd'}}$ . See comprehensions. single dispatch A form of generic function dispatch where the implementation is chosen based on the type of a single argument. slice An object usually containing a portion of a sequence . A slice is created using the subscript notation,$_{[]}$ with colons between numbers when several are given, such as in$_{variable_name[1:3:5]}$ . The bracket (sub- script) notation uses$_{slice}$objects internally. special method A method that is called implicitly by Python to execute a certain operation on a type, such as addition. Such methods have names starting and ending with double underscores. Special methods are documented in specialnames. statement A statement is part of a suite (a “block” of code). A statement is either an expression or one of several constructs with a keyword, such as$_{if}$,$_{while}$ or$_{for}$. text encoding A codec which encodes Unicode strings to bytes. text file A file object able to read and write$_{str}$objects. Often, a text file actually accesses a byte-oriented datastream and handles the text encoding automatically. Examples of text files are files opened in text mode ($_{'r'}$ or$_{'w'}$ ), sys.stdin ,$_{sys.stdout}$ , and instances of$_{io.StringIO}$. triple-quoted string A string which is bound by three instances of either a quotation mark (“) or an apostrophe (‘). While they don’t provide any functionality not available with single-quoted strings, they are useful for a number of reasons. They allow you to include unescaped single and double quotes within a string and they can span multiple lines without the use of the continuation character, making them especially useful when writing docstrings. type The type of a Python object determines what kind of object it is; every object has a type. An object’s type is accessible as its$_{__class__}$ attribute or can be retrieved with$_{type(obj)}$ . type alias A synonym for a type, created by assigning the type to an identifier. See also binary file for a file object able to read and write bytes-like objects . Type aliases are useful for simplifying type hints . For example: The collections.abc.Sequence abstract base class defines a much richer interface that goes be- yond just$_{__getitem__()}$ and$_{__len__()}$ , adding$_{count()}$ ,$_{index()}$ ,$_{__contains__()}$ , and __reversed__() . Types that implement this expanded interface can be registered explicitly using register() . See also namespace package . regular package A traditional package , such as a directory containing an$_{__init__.py}$ file. 75