- Glossary - S
- ********
- __slots__
- A declaration inside a class that saves memory by pre-declaring
- space for instance attributes and eliminating 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__()" special method and defines a
- "__len__()" method that returns the length of the sequence. Some
- built-in sequence 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.
- The "collections.abc.Sequence" abstract base class defines a much
- richer interface that goes beyond just "__getitem__()" and
- "__len__()", adding "count()", "index()", "__contains__()", and
- "__reversed__()". Types that implement this expanded interface can
- be registered explicitly using "register()".
- 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 Displays for lists, sets and dictionaries.
- 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 (subscript) 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 Special method names.
- 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".
- strong reference
- In Python's C API, a strong reference is a reference to an object
- which increments the object's reference count when it is created
- and decrements the object's reference count when it is deleted.
- The "Py_NewRef()" function can be used to create a strong reference
- to an object. Usually, the "Py_DECREF()" function must be called on
- the strong reference before exiting the scope of the strong
- reference, to avoid leaking one reference.
- See also *borrowed reference*.
- Python Slice Notation Tutorial - How to Slice Strings and Lists Explained with Examples (+ Reverse)
Python software and documentation are licensed under the PSF License Agreement.
Starting with Python 3.8.6, examples, recipes, and other code in the documentation are dual licensed under the PSF License Agreement and the Zero-Clause BSD license.
Some software incorporated into Python is under different licenses. The licenses are listed with code falling under that license. See Licenses and Acknowledgements for Incorporated Software for an incomplete list of these licenses.
Python and it's documentation is:
Copyright © 2001-2022 Python Software Foundation. All rights reserved.
Copyright © 2000 BeOpen.com. All rights reserved.
Copyright © 1995-2000 Corporation for National Research Initiatives. All rights reserved.
Copyright © 1991-1995 Stichting Mathematisch Centrum. All rights reserved.
See History and License for complete license and permissions information:
https://docs.python.org/3/license.html#psf-license