mirror of
https://github.com/freeCodeCamp/freeCodeCamp.git
synced 2026-05-22 19:02:54 -04:00
fix(curriculum): removed decorators section from python review (#64800)
This commit is contained in:
@@ -626,27 +626,6 @@ print(int(True)) # 1
|
||||
print(int(False)) # 0
|
||||
```
|
||||
|
||||
## Decorators
|
||||
|
||||
- **Definition**: Decorators are a special kind of function in Python. They are like wrappers for other functions, so they take another function as an argument.
|
||||
|
||||
```py
|
||||
def say_hello():
|
||||
name = input('What is your name? ')
|
||||
return 'Hello ' + name
|
||||
|
||||
def uppercase_decorator(func):
|
||||
def wrapper():
|
||||
original_func = func()
|
||||
modified_func = original_func.upper()
|
||||
return modified_func
|
||||
return wrapper
|
||||
|
||||
say_hello_res = uppercase_decorator(say_hello)
|
||||
|
||||
print(say_hello_res())
|
||||
```
|
||||
|
||||
## Scope in Python
|
||||
|
||||
- **Local Scope**: This is when a variable declared inside a function or class can only be accessed within that function or class.
|
||||
|
||||
@@ -626,27 +626,6 @@ print(int(True)) # 1
|
||||
print(int(False)) # 0
|
||||
```
|
||||
|
||||
## Decorators
|
||||
|
||||
- **Definition**: Decorators are a special kind of function in Python. They are like wrappers for other functions, so they take another function as an argument.
|
||||
|
||||
```py
|
||||
def say_hello():
|
||||
name = input('What is your name? ')
|
||||
return 'Hello ' + name
|
||||
|
||||
def uppercase_decorator(func):
|
||||
def wrapper():
|
||||
original_func = func()
|
||||
modified_func = original_func.upper()
|
||||
return modified_func
|
||||
return wrapper
|
||||
|
||||
say_hello_res = uppercase_decorator(say_hello)
|
||||
|
||||
print(say_hello_res())
|
||||
```
|
||||
|
||||
## Scope in Python
|
||||
|
||||
- **Local Scope**: This is when a variable declared inside a function or class can only be accessed within that function or class.
|
||||
|
||||
Reference in New Issue
Block a user