<commit_before>
### Higher Order Functions

Exploring dynamic argument and keyword quantities, nested functions, higher order functions, closures, and decorators.

If you get behind in this lesson, just keep typing/copying/running code. The topic is hard at first, so if it feels hard, things are going as planned.

1. Nesting Functions - How does Python resolve names?
    1. LEGB?  Local, Enclosing, Global, Built-in.
    2. In other words, if Python finds a variable name in a function, then it will stop looking even if the function is in the global scope.
    3. See nesting_functions examples.


2. Using `(*args, **kwargs)`:
    1. No discussion topic - see args_kwargs examples.


3. How to get a nested function to close. Also known as a closure.
    1. **A what?** A [closure](http://en.wikipedia.org/wiki/Closure_(computer_programming)) - Simple definition: A function that binds a set of 'private' variables.
    2. **How does this help me write useful code?** 
        1. Control flow
        2. Private functions for specific environments
        3. Passing variables to a function based on the context of the function.
    3. **Why not just put the environment in the global scope?** You could. 
        1. Security, 
        2. compartmentalization, 
        3. memory efficiency, code reusability.  
        4. Closures are a sophisticated, optional tool.


4. Decorators 
    1. lorem ipsum


5. Functools - What's a partial?
    1. lorem ipsum



Preparing for this lesson:<commit_msg>Updated hof copy.<commit_after>
### Higher Order Functions

Exploring dynamic argument and keyword quantities, nested functions, higher order functions, closures, and decorators.

If you get behind in this lesson, just keep typing/copying/running code. The topic is hard at first, so if it feels hard, things are going as planned.

1. Nesting Functions - How does Python resolve names?
    _1. LEGB?  Local, Enclosing, Global, Built-in
    _2. Python stops looking when it finds a variable defined. So if it exists in local and global scope, Python will use the local scope.
    _3. See nesting_functions examples


2. Using `(*args, **kwargs)`:
    1. No discussion topic - see args_kwargs examples


3. How to get a nested function to close. Also known as a closure.
    _1. **A what?** A [closure](http://en.wikipedia.org/wiki/Closure_(computer_programming)) - Simple definition: A function that binds a set of 'private' variables.
    _2. **How does this help me write useful code?** 
        __1. Control flow
        __2. Private functions for specific environments
        __3. Passing variables to a function based on the context of the function
    _3. **Why not just put the environment in the global scope?** You could. 
        __1. Security
        __2. compartmentalization
        __3. memory efficiency, code reusability
        __4. Closures are a sophisticated, optional tool


4. Decorators 
    1. [PEP318](https://www.python.org/dev/peps/pep-0318/)
    2. A decorator encloses a method or function. 
    3. [Decorator Reference Syntax](https://docs.python.org/2/reference/compound_stmts.html#function-definitions)
    4. 


5. Functools - What's a partial?
    1. lorem ipsum



Preparing for this lesson:
{'fraction_non_alphanumeric': 0.07554179566563468, 'fraction_numerical': 0.016408668730650156, 'mean_word_length': 3.0950570342205324, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 3, 'https://': 2, 'lorem ipsum': 3, 'www.': 1, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '5322052', 'n_tokens_mistral': 933, 'n_tokens_neox': 865, 'n_words': 427}