From 21d2a03b8d120d011fe99b0b29780ea29077d690 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jure=20=C5=A0orn?= Date: Fri, 5 Jul 2019 01:06:46 +0200 Subject: [PATCH] Partial --- README.md | 2 ++ index.html | 4 ++++ 2 files changed, 6 insertions(+) diff --git a/README.md b/README.md index bb7e537..8faf075 100644 --- a/README.md +++ b/README.md @@ -827,6 +827,8 @@ from functools import partial >>> multiply_by_3(10) 30 ``` +* **Partial is useful in cases when a function needs to be passed as an argument, because it enables us to set the arguments beforehand.** +* **A few examples being `'defaultdict()'`, `'iter(, to_exclusive)'` and dataclass's `'field(default_factory=)'`.** ### Nonlocal **If variable is being assigned to anywhere in the scope, it is regarded as a local variable, unless it is declared as a 'global' or a 'nonlocal'.** diff --git a/index.html b/index.html index bbd8713..3514baf 100644 --- a/index.html +++ b/index.html @@ -801,6 +801,10 @@ creature = Creature(Point(0, >>> multiply_by_3(10) 30 +
    +
  • Partial is useful in cases when a function needs to be passed as an argument, because it enables us to set the arguments beforehand.
  • +
  • A few examples being 'defaultdict(<function>)', 'iter(<function>, to_exclusive)' and dataclass's 'field(default_factory=<function>)'.
  • +

Nonlocal

If variable is being assigned to anywhere in the scope, it is regarded as a local variable, unless it is declared as a 'global' or a 'nonlocal'.

def get_counter():