Skip to content

Instantly share code, notes, and snippets.

@nooperpudd
Created August 30, 2018 13:03
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save nooperpudd/cb70bd03a6378c3947a87677251eed57 to your computer and use it in GitHub Desktop.
Save nooperpudd/cb70bd03a6378c3947a87677251eed57 to your computer and use it in GitHub Desktop.
context lib management
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()
@nooperpudd
Copy link
Author

Here is some non-HTML

@nooperpudd
Copy link
Author

<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