Conteúdo do Curso
Mastering Python: Closures and Decorators
Mastering Python: Closures and Decorators
Challenge: Text Cache
Tarefa
Implement the string_cache()
function that returns the inner()
function that takes the string value and adds it to the enclosed text.
- Create the
text
variable with the value""
(empty string) in thestring_cache()
function. - The
inner()
function should take thestring
argument with the default value""
. - Make the
text
non-local variable changeable inside theinner()
function. - If the
string
argument is not an empty string, add this string to thetext
non-local variable. After the first string addition, the addition should be with space. - The
inner()
function should return thetext
enclosed variable. - The
string_cache()
should return theinner()
function without calling. - Call the
string_cache()
function and assign the result to thetext_cache
variable.
Obrigado pelo seu feedback!
Challenge: Text Cache
Tarefa
Implement the string_cache()
function that returns the inner()
function that takes the string value and adds it to the enclosed text.
- Create the
text
variable with the value""
(empty string) in thestring_cache()
function. - The
inner()
function should take thestring
argument with the default value""
. - Make the
text
non-local variable changeable inside theinner()
function. - If the
string
argument is not an empty string, add this string to thetext
non-local variable. After the first string addition, the addition should be with space. - The
inner()
function should return thetext
enclosed variable. - The
string_cache()
should return theinner()
function without calling. - Call the
string_cache()
function and assign the result to thetext_cache
variable.
Obrigado pelo seu feedback!
Challenge: Text Cache
Tarefa
Implement the string_cache()
function that returns the inner()
function that takes the string value and adds it to the enclosed text.
- Create the
text
variable with the value""
(empty string) in thestring_cache()
function. - The
inner()
function should take thestring
argument with the default value""
. - Make the
text
non-local variable changeable inside theinner()
function. - If the
string
argument is not an empty string, add this string to thetext
non-local variable. After the first string addition, the addition should be with space. - The
inner()
function should return thetext
enclosed variable. - The
string_cache()
should return theinner()
function without calling. - Call the
string_cache()
function and assign the result to thetext_cache
variable.
Obrigado pelo seu feedback!
Tarefa
Implement the string_cache()
function that returns the inner()
function that takes the string value and adds it to the enclosed text.
- Create the
text
variable with the value""
(empty string) in thestring_cache()
function. - The
inner()
function should take thestring
argument with the default value""
. - Make the
text
non-local variable changeable inside theinner()
function. - If the
string
argument is not an empty string, add this string to thetext
non-local variable. After the first string addition, the addition should be with space. - The
inner()
function should return thetext
enclosed variable. - The
string_cache()
should return theinner()
function without calling. - Call the
string_cache()
function and assign the result to thetext_cache
variable.