Skip to content

Instantly share code, notes, and snippets.

data "google_storage_bucket_object" "picture" {
name = "folder/butterfly01.jpg"
bucket = "image-store"
}
locals {
service_name = "forum"
owner = "Community Team"
}
module "consul" {
source = "github.com/hashicorp/example"
}
# This is the original function.
def orig_func(a,b,c):
"""
This is the original function
returns the product of a,b,c
"""
return (print('This is the product:',a*b*c))
def decor_func(fn):
def wrapper_func(*args,**kwargs):
"""
This is the wrapper function
"""
print('Execute this code before the main function is executed')
return fn(*args, **kwargs)
return wrapper_func
orig_func(7,9,11)
#Method:1
orig_func=decor_func(orig_func)
# or
#Method2
@decor_func
def orig_func(a,b,c):
"""
returns the product of a,b,c
help(orig_func)
def decor_func(fn):
def wrapper_func(*args,**kwargs):
"""
This is the wrapper function
"""
print('Execute this code before the main function is executed')
return fn(*args, **kwargs)
#Assign the original function name and the docstring to the wrapper name and doctstring.
wrapper_func.__name__ = fn.__name__
def decor_func(fn):
@wraps(fn)
def wrapper_func(*args,**kwargs):
"""
This is the wrapper function
"""
print('Execute this code before the main function is executed')
return fn(*args, **kwargs)
return wrapper_func