I tried Python> decorator

@ Introducing Python: Modern Computing in Simple Packages by Bill Lubanovic (No. 2777 / 12833)

There seems to be a feature called decorator.

I've tried.

http://ideone.com/6rPiXX

def decorate_it(func):
	def new_function(*args, **kwargs):
		print('***MAY I HAVE YOUR ATTENTION, PLEASE***')
		print('This is 7of9, Tertiary Adjunct of Unimatrix Zero One.')
		print('I have something to tell you, today')
		result = func(*args, **kwargs)
		print('Thank you for your attention')
		print('Have a good day')
		print('By the way, your aunt has often told me that ...')
		return result
	return new_function
	
def say_hello(word):
	print(word)

@decorate_it
def say_decorated(word):
	print(word)
	
say_hello('Nice to meet you')
say_decorated('Nice seeing you')

run


Success	time: 0.01 memory: 28384 signal:0
Nice to meet you
***MAY I HAVE YOUR ATTENTION, PLEASE***
This is 7of9, Tertiary Adjunct of Unimatrix Zero One.
I have something to tell you, today
Nice seeing you
Thank you for your attention
Have a good day
By the way, your aunt has often told me that ...

Recommended Posts

I tried Python> decorator
I tried Python> autopep8
I tried fp-growth with python
I tried scraping with Python
I tried Python C extension
[Python] I tried using OpenPose
I tried gRPC with Python
I tried scraping with python
I tried to touch Python (installation)
I tried web scraping with python.
I tried using Thonny (Python / IDE)
I tried Grumpy (Go running Python).
I tried running prolog with python 3.8.2.
I tried Line notification in Python
I tried SMTP communication with Python
[Python] I tried using YOLO v3
Note: Python Decorator
I tried scraping
I tried PyQ
I started python
I tried AutoKeras
I tried papermill
I tried django-slack
I tried Django
Python function decorator
I tried spleeter
I tried cgo
I tried to summarize Python exception handling
I tried to implement PLSA in Python
I tried to implement permutation in Python
Wrangle x Python book I tried it [2]
I tried scraping Yahoo News with Python
I tried to implement PLSA in Python 2
I tried using Bayesian Optimization in Python
I tried non-photorealistic rendering with Python + opencv
I tried using UnityCloudBuild API from Python
I tried to implement ADALINE in Python
I tried a functional language with Python
I tried recursion with Python ② (Fibonacci sequence)
I tried to implement PPO in Python
Python: I tried the traveling salesman problem
Mayungo's Python Learning Episode 8: I tried input
[Python] I tried to calculate TF-IDF steadily
I tried scraping Yahoo weather (Python edition)
I tried to touch Python (basic syntax)
I tried the Python Tornado Testing Framework
#I tried something like Vlookup with Python # 2
I tried using parameterized
[Python / DynamoDB / boto3] List of operations I tried
I tried "smoothing" the image with Python + OpenCV
I tried using argparse
I tried hundreds of millions of SQLite with python
I tried using mimesis
[Python] I tried substituting the function name for the function name
I tried using anytree
I tried competitive programming
I tried web scraping using python and selenium
I tried running pymc
I tried ARP spoofing
I tried using aiomysql
I tried object detection using Python and OpenCV