Skip to main content
Join the official 2020 Python Developers SurveyStart the survey!

Write html to a file like object, using a pythonic syntax.

Project description

htmlwrite is a python library for writing html to a file like object, using a pythonic syntax. Use as an alternative to templating engines.

>>> import sys
>>>
>>> from htmlwrite import Writer, Tag
>>>
>>> writer = Writer(sys.stdout)
>>> w = writer.write
>>> c = writer.context
>>>
>>> with c(Tag('html')):
...     with c(Tag('body')):
...         with c(Tag('div', class_=('foo', ), s_font_weight='bold')):
...             w('Hello world  ')
...         w(Tag('div'), 'ok, bye.')
...
<html>
  <body>
    <div class="foo" style="font-weight: bold;">
      Hello world
    </div>
    <div>ok, bye.</div>
  </body>
</html>

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Files for htmlwrite, version 0.7.0
Filename, size File type Python version Upload date Hashes
Filename, size htmlwrite-0.7.0.tar.gz (6.6 kB) File type Source Python version None Upload date Hashes View

Supported by

Pingdom Pingdom Monitoring Google Google Object Storage and Download Analytics Sentry Sentry Error logging AWS AWS Cloud computing DataDog DataDog Monitoring Fastly Fastly CDN DigiCert DigiCert EV certificate StatusPage StatusPage Status page