The text below is selected, press Ctrl+C to copy to your clipboard. (⌘+C on Mac) No line numbers will be copied.
Guest
Python Glossary: terms starting with letter D
By Guest on 13th November 2022 01:14:58 AM | Syntax: PYTHON | Views: 187



New Paste New paste | Download Paste Download | Toggle Line Numbers Show/Hide line no. | Copy Paste Copy text to clipboard
  1. Glossary - D
  2. ********
  3.  
  4. decorator
  5.    A function returning another function, usually applied as a
  6.    function transformation using the "@wrapper" syntax.  Common
  7.    examples for decorators are "classmethod()" and "staticmethod()".
  8.  
  9.    The decorator syntax is merely syntactic sugar, the following two
  10.    function definitions are semantically equivalent:
  11.  
  12.       def f(arg):
  13.           ...
  14.       f = staticmethod(f)
  15.  
  16.       @staticmethod
  17.       def f(arg):
  18.           ...
  19.  
  20.    The same concept exists for classes, but is less commonly used
  21.    there.  See the documentation for function definitions and class
  22.    definitions for more about decorators.
  23.  
  24. descriptor
  25.    Any object which defines the methods "__get__()", "__set__()", or
  26.    "__delete__()".  When a class attribute is a descriptor, its
  27.    special binding behavior is triggered upon attribute lookup.
  28.    Normally, using *a.b* to get, set or delete an attribute looks up
  29.    the object named *b* in the class dictionary for *a*, but if *b* is
  30.    a descriptor, the respective descriptor method gets called.
  31.    Understanding descriptors is a key to a deep understanding of
  32.    Python because they are the basis for many features including
  33.    functions, methods, properties, class methods, static methods, and
  34.    reference to super classes.
  35.  
  36.    For more information about descriptors' methods, see Implementing
  37.   Descriptors or the Descriptor How To Guide.
  38.  
  39. dictionary
  40.   An associative array, where arbitrary keys are mapped to values.
  41.   The keys can be any object with "__hash__()" and "__eq__()"
  42.   methods. Called a hash in Perl.
  43.  
  44. dictionary comprehension
  45.   A compact way to process all or part of the elements in an iterable
  46.   and return a dictionary with the results. "results = {n: n ** 2 for
  47.   n in range(10)}" generates a dictionary containing key "n" mapped
  48.   to value "n ** 2". See Displays for lists, sets and dictionaries.
  49.  
  50. dictionary view
  51.   The objects returned from "dict.keys()", "dict.values()", and
  52.   "dict.items()" are called dictionary views. They provide a dynamic
  53.   view on the dictionary’s entries, which means that when the
  54.   dictionary changes, the view reflects these changes. To force the
  55.   dictionary view to become a full list use "list(dictview)".  See
  56.   Dictionary view objects.
  57.  
  58. docstring
  59.   A string literal which appears as the first expression in a class,
  60.   function or module.  While ignored when the suite is executed, it
  61.   is recognized by the compiler and put into the "__doc__" attribute
  62.   of the enclosing class, function or module.  Since it is available
  63.   via introspection, it is the canonical place for documentation of
  64.   the object.
  65.  
  66. duck-typing
  67.   A programming style which does not look at an object's type to
  68.    determine if it has the right interface; instead, the method or
  69.    attribute is simply called or used ("If it looks like a duck and
  70.   quacks like a duck, it must be a duck.")  By emphasizing interfaces
  71.    rather than specific types, well-designed code improves its
  72.    flexibility by allowing polymorphic substitution.  Duck-typing
  73.    avoids tests using "type()" or "isinstance()".  (Note, however,
  74.    that duck-typing can be complemented with *abstract base classes*.)
  75.    Instead, it typically employs "hasattr()" tests or *EAFP*
  76.    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
  • Recent Pastes