This is very much the kind of thing that would belong in a library. There's probably more than one out there right now. In fact, way back when I started learning Python (almost 20 yrs ago!)), there was such a lib -- I think it was called HTMLgen. However, since then, most people have decided that templating is the way to accomplish this -- write the html with bits of code in in, and have it generate the final html. There are many template engines for/with Python.
Having said that, I actually use an OO html generator as an assignment in my training: https://uwpce-pythoncert.github.io/PythonCertDevel/exercises/html_renderer.html So you can write it yourself... Using the approach in that assignment, you would write your example as: selector = Selector(_class="eggs") for i in range(3): Selector.append(Option(f"Option {i}")) selector.render() -CHB On Thu, Mar 14, 2019 at 3:43 PM Steven D'Aprano <st...@pearwood.info> wrote: > Hi Vlad, and welcome! > > On Thu, Mar 14, 2019 at 10:00:03PM +0100, Vlad Tudorache wrote: > > Hello, > > > > I'd like to know if there is a basic HTML wrapper for Python, like > > TextWrapper but allowing the generation of HTML from strings or iterables > > of strings. > > This list is for proposing and discussing ideas for new syntax or > functionality for the Python language, not for asking basic support > questions. > > Are you are proposing that Python gets a HTML wrapper? > > If so, it is up to you to do your research first, so that you know the > answer to your question before you propose the idea. You should be able > to tell us what options are available as language features or > third-party libraries. > > If you don't know the answer, there are many places you can ask, > starting with Google and other search engines: > > https://duckduckgo.com/?q=python+html+generator > > and others such as Reddit's /r/learnpython subreddit, Stackoverflow, the > Python-List mailing list, the Python IRC channel, and more. > > https://mail.python.org/mailman/listinfo/python-list > news:comp.lang.python > https://www.reddit.com/r/learnpython/ > https://www.python.org/community/irc/ > > If you still have a proposal after doing your research, we're happy to > hear it. > > > Regards, > > > > Steven > _______________________________________________ > Python-ideas mailing list > Python-ideas@python.org > https://mail.python.org/mailman/listinfo/python-ideas > Code of Conduct: http://python.org/psf/codeofconduct/ > -- Christopher Barker, PhD Python Language Consulting - Teaching - Scientific Software Development - Desktop GUI and Web Development - wxPython, numpy, scipy, Cython
_______________________________________________ Python-ideas mailing list Python-ideas@python.org https://mail.python.org/mailman/listinfo/python-ideas Code of Conduct: http://python.org/psf/codeofconduct/