Created
August 30, 2018 13:03
-
-
Save nooperpudd/cb70bd03a6378c3947a87677251eed57 to your computer and use it in GitHub Desktop.
context lib management
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
from contextlib import ContextDecorator | |
class makeparagraph(ContextDecorator): | |
def __enter__(self): | |
print('<p>') | |
return self | |
def __exit__(self, *exc): | |
print('</p>') | |
return False | |
@makeparagraph() | |
def emit_html(): | |
print('Here is some non-HTML') | |
emit_html() |
<p>
Here is some non-HTML
</p>
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Here is some non-HTML