diff --git a/concepts/decorators/.meta/config.json b/concepts/decorators/.meta/config.json index 9b9e8da5a9b..57692af26e6 100644 --- a/concepts/decorators/.meta/config.json +++ b/concepts/decorators/.meta/config.json @@ -1,5 +1,5 @@ { - "blurb": "TODO: add blurb for this concept", - "authors": ["bethanyg", "cmccandless"], + "blurb": "Decorators are higher-order functions that take other functions as arguments to extend/modify their behavior and return the modified functions.", + "authors": ["BethanyG", "bobahop", "kotp", "mathstrains21", "velaco"], "contributors": [] } diff --git a/concepts/decorators/introduction.md b/concepts/decorators/introduction.md index fcde74642ca..5bfc4720f20 100644 --- a/concepts/decorators/introduction.md +++ b/concepts/decorators/introduction.md @@ -1,2 +1,7 @@ -#TODO: Add introduction for this concept. +# Introduction +Functions are first-class objects in Python, which means they can also be passed as arguments to other functions. +Decorators are [higher-order functions][hofunc] that take another function as an argument and return it after extending or modifying its behavior. +Decorators are defined in the same way as any other function, but they are applied on the line above the functions they are decorating using the `@` symbol before their names (`@my_decorator`). While they can take multiple arguments, decorators must take _at least_ the function they are decorating as an argument. + +[hofunc]:https://en.wikipedia.org/wiki/Higher-order_function diff --git a/concepts/decorators/links.json b/concepts/decorators/links.json index eb5fb7c38a5..dfaa663c436 100644 --- a/concepts/decorators/links.json +++ b/concepts/decorators/links.json @@ -1,18 +1,22 @@ [ { - "url": "http://example.com/", - "description": "TODO: add new link (above) and write a short description here of the resource." + "url": "https://peps.python.org/pep-0318/", + "description": "PEP 318 – Decorators for Functions and Methods" }, { - "url": "http://example.com/", - "description": "TODO: add new link (above) and write a short description here of the resource." + "url": "https://www.geeksforgeeks.org/first-class-functions-python/", + "description": "First Class Functions in Python" }, { - "url": "http://example.com/", - "description": "TODO: add new link (above) and write a short description here of the resource." + "url": "https://www.geeksforgeeks.org/higher-order-functions-in-python/", + "description": "Higher Order Functions in Python" }, { - "url": "http://example.com/", - "description": "TODO: add new link (above) and write a short description here of the resource." + "url": "https://realpython.com/primer-on-python-decorators/", + "description": "Primer on Python Decorators" + }, + { + "url": "https://www.geeksforgeeks.org/chain-multiple-decorators-in-python/", + "description": "Chain Multiple Decorators in Python" } ]