<div dir="ltr"><div dir="ltr">This is very much the kind of thing that would belong in a library.<div><br></div><div>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.</div><div><br></div><div>Having said that, I actually use an OO  html generator as an assignment in my training:</div><div><br></div><div><a href="https://uwpce-pythoncert.github.io/PythonCertDevel/exercises/html_renderer.html">https://uwpce-pythoncert.github.io/PythonCertDevel/exercises/html_renderer.html</a><br></div><div><br></div><div>So you can write it yourself...</div><div><br></div><div>Using the approach in that assignment, you would write your example as:</div><div><br></div><div><font face="monospace, monospace">selector = Selector(_class="eggs")</font></div><div><font face="monospace, monospace">for i in range(3):</font></div><div><font face="monospace, monospace">    Selector.append(Option(f"Option {i}"))</font></div><div><font face="monospace, monospace"><br></font></div><div><font face="monospace, monospace">selector.render()</font></div><div><br></div><div>-CHB</div><div><br></div><div><br></div></div></div><br><div class="gmail_quote"><div dir="ltr" class="gmail_attr">On Thu, Mar 14, 2019 at 3:43 PM Steven D'Aprano <<a href="mailto:steve@pearwood.info">steve@pearwood.info</a>> wrote:<br></div><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex">Hi Vlad, and welcome!<br>
<br>
On Thu, Mar 14, 2019 at 10:00:03PM +0100, Vlad Tudorache wrote:<br>
> Hello,<br>
> <br>
> I'd like to know if there is a basic HTML wrapper for Python, like<br>
> TextWrapper but allowing the generation of HTML from strings or iterables<br>
> of strings.<br>
<br>
This list is for proposing and discussing ideas for new syntax or <br>
functionality for the Python language, not for asking basic support <br>
questions.<br>
<br>
Are you are proposing that Python gets a HTML wrapper? <br>
<br>
If so, it is up to you to do your research first, so that you know the <br>
answer to your question before you propose the idea. You should be able <br>
to tell us what options are available as language features or <br>
third-party libraries.<br>
<br>
If you don't know the answer, there are many places you can ask, <br>
starting with Google and other search engines:<br>
<br>
<a href="https://duckduckgo.com/?q=python+html+generator" rel="noreferrer" target="_blank">https://duckduckgo.com/?q=python+html+generator</a><br>
<br>
and others such as Reddit's /r/learnpython subreddit, Stackoverflow, the <br>
Python-List mailing list, the Python IRC channel, and more.<br>
<br>
<a href="https://mail.python.org/mailman/listinfo/python-list" rel="noreferrer" target="_blank">https://mail.python.org/mailman/listinfo/python-list</a><br>
news:comp.lang.python<br>
<a href="https://www.reddit.com/r/learnpython/" rel="noreferrer" target="_blank">https://www.reddit.com/r/learnpython/</a><br>
<a href="https://www.python.org/community/irc/" rel="noreferrer" target="_blank">https://www.python.org/community/irc/</a><br>
<br>
If you still have a proposal after doing your research, we're happy to <br>
hear it.<br>
<br>
<br>
Regards,<br>
<br>
<br>
<br>
Steven<br>
_______________________________________________<br>
Python-ideas mailing list<br>
<a href="mailto:Python-ideas@python.org" target="_blank">Python-ideas@python.org</a><br>
<a href="https://mail.python.org/mailman/listinfo/python-ideas" rel="noreferrer" target="_blank">https://mail.python.org/mailman/listinfo/python-ideas</a><br>
Code of Conduct: <a href="http://python.org/psf/codeofconduct/" rel="noreferrer" target="_blank">http://python.org/psf/codeofconduct/</a><br>
</blockquote></div><br clear="all"><div><br></div>-- <br><div dir="ltr" class="gmail_signature">Christopher Barker, PhD<br><br> Python Language Consulting<br>  - Teaching<br>  - Scientific Software Development<br>  - Desktop GUI and Web Development<br>  - wxPython, numpy, scipy, Cython<br></div>