- Glossary - D
- ********
- decorator
- A function returning another function, usually applied as a
- function transformation using the "@wrapper" syntax. Common
- examples for decorators are "classmethod()" and "staticmethod()".
- The decorator syntax is merely syntactic sugar, the following two
- function definitions are semantically equivalent:
- def f(arg):
- ...
- f = staticmethod(f)
- @staticmethod
- def f(arg):
- ...
- The same concept exists for classes, but is less commonly used
- there. See the documentation for function definitions and class
- definitions for more about decorators.
- descriptor
- Any object which defines the methods "__get__()", "__set__()", or
- "__delete__()". When a class attribute is a descriptor, its
- special binding behavior is triggered upon attribute lookup.
- Normally, using *a.b* to get, set or delete an attribute looks up
- the object named *b* in the class dictionary for *a*, but if *b* is
- a descriptor, the respective descriptor method gets called.
- Understanding descriptors is a key to a deep understanding of
- Python because they are the basis for many features including
- functions, methods, properties, class methods, static methods, and
- reference to super classes.
- For more information about descriptors' methods, see Implementing
- Descriptors or the Descriptor How To Guide.
- dictionary
- An associative array, where arbitrary keys are mapped to values.
- The keys can be any object with "__hash__()" and "__eq__()"
- methods. Called a hash in Perl.
- dictionary comprehension
- A compact way to process all or part of the elements in an iterable
- and return a dictionary with the results. "results = {n: n ** 2 for
- n in range(10)}" generates a dictionary containing key "n" mapped
- to value "n ** 2". See Displays for lists, sets and dictionaries.
- dictionary view
- The objects returned from "dict.keys()", "dict.values()", and
- "dict.items()" are called dictionary views. They provide a dynamic
- view on the dictionary’s entries, which means that when the
- dictionary changes, the view reflects these changes. To force the
- dictionary view to become a full list use "list(dictview)". See
- Dictionary view objects.
- docstring
- A string literal which appears as the first expression in a class,
- function or module. While ignored when the suite is executed, it
- is recognized by the compiler and put into the "__doc__" attribute
- of the enclosing class, function or module. Since it is available
- via introspection, it is the canonical place for documentation of
- the object.
- duck-typing
- A programming style which does not look at an object's type to
- determine if it has the right interface; instead, the method or
- attribute is simply called or used ("If it looks like a duck and
- quacks like a duck, it must be a duck.") By emphasizing interfaces
- rather than specific types, well-designed code improves its
- flexibility by allowing polymorphic substitution. Duck-typing
- avoids tests using "type()" or "isinstance()". (Note, however,
- that duck-typing can be complemented with *abstract base classes*.)
- Instead, it typically employs "hasattr()" tests or *EAFP*
- programming.
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