Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- change_word = 'хлеб'
- def decorator(word_or_func='колбаса'):
- def decore(func, *args):
- arg_list = [func, *args] if not callable(func) else args
- func = word_or_func if callable(word_or_func) else func
- new_word = word_or_func if type(word_or_func) == str else 'колбаса'
- def wrapper(*arg_list):
- some_list = list(arg_list)
- return_list = []
- for phrase in some_list:
- if change_word in phrase:
- return_list.append(phrase.replace(change_word, new_word, -1))
- else:
- return_list.append(phrase)
- return func(*return_list)
- return wrapper(*arg_list) if callable(word_or_func) else wrapper
- return decore
- @decorator()
- def text(*args):
- print(*args, sep='\n', end='\n')
- text('хлеб всему голова', 'хлеб-соль', 'хлебное место', 'без соли хлеб не еда')
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement