fix(guide): simplify directory structure

This commit is contained in:
Mrugesh Mohapatra
2018-10-16 21:26:13 +05:30
parent f989c28c52
commit da0df12ab7
35752 changed files with 0 additions and 317652 deletions

View File

@ -0,0 +1,40 @@
---
title: Decorator
---
The decorator is a design pattern that could modify or enhance the interface of a class.
## Decorator in Python3
Here is an example of Decorator implementation in Python3.
```python
class MyText(object):
def __init__(self, text=''):
self.text = text
def __str__(self):
return 'This is {}'.format(self.text)
class BracketDecorator(object):
def __init__(self, decoratee):
self._decoratee = decoratee
def __str__(self):
return '({})'.format(self._decoratee)
class QuoteDecorator(object):
def __init__(self, decoratee):
self._decoratee = decoratee
def __str__(self):
return '\"{}\"'.format(self._decoratee)
print(BracketDecorator(MyText('apple')))
>>> (This is apple)
print(QuoteDecorator(MyText('banana')))
>>> "This is banana"
```