<story><title>Brython – A Python 3 implementation for client-side web programming</title><url>https://brython.info/</url></story><parent_chain><item><author>linkdd</author><text>What is this monstrosity in the tutorial ?&lt;p&gt;&amp;gt;&amp;gt;&amp;gt; document &amp;lt;= &amp;#x27;Hello!&amp;#x27;  # write in the DOM&lt;p&gt;Since when the __le__ method has any side effects?&lt;p&gt;So to sum it up:&lt;p&gt;- it runs inside the Javascript VM&lt;p&gt;- you change the syntax by breaking the semantics&lt;p&gt;- the import mechanisms is completely different&lt;p&gt;Is it still Python then ?&lt;p&gt;NB: Still, it&amp;#x27;s a fun project and hope you had fun making it.</text></item></parent_chain><comment><author>wenc</author><text>Looks like the FAQ covers this question:&lt;p&gt;&lt;a href=&quot;https:&amp;#x2F;&amp;#x2F;brython.info&amp;#x2F;static_doc&amp;#x2F;en&amp;#x2F;faq.html&quot; rel=&quot;nofollow&quot;&gt;https:&amp;#x2F;&amp;#x2F;brython.info&amp;#x2F;static_doc&amp;#x2F;en&amp;#x2F;faq.html&lt;/a&gt;&lt;p&gt;Quote:&lt;p&gt;Q: why use the operator &amp;lt;= to build the tree of DOM elements? This is not pythonic!&lt;p&gt;A: Python has no built-in structure to manipulate trees, ie to add &amp;quot;child&amp;quot; or &amp;quot;sibling&amp;quot; nodes to a tree node. For these operations, functions can be used; the syntax proposed by Brython is to use operators: this is easier to type (no parenthesis) and more readable&lt;p&gt;To add a sibling node, the operator + is used.&lt;p&gt;To add a child, the operator &amp;lt;= was chosen for these reasons:&lt;p&gt;* it has the shape of a left arrow; note that Python function annotations use a new operator -&amp;gt; that was chosen for its arrow shape&lt;p&gt;* it looks like an augmented assignment because of the equal sign&lt;p&gt;* it can&amp;#x27;t be confused with &amp;quot;lesser or equal&amp;quot; because a line with document &amp;lt;= elt would be a no-op if it was &amp;quot;lesser or equal&amp;quot;, which is always used in a condition or as the return value of a function&lt;p&gt;* we are so used to interpret the 2 signs &amp;lt; and = as &amp;quot;lesser or equal&amp;quot; that we forget that they are a convention for programming languages, to replace the real sign ≤&lt;p&gt;* in Python, &amp;lt;= is used as an operator for sets with a different meaning than &amp;quot;lesser or equal&amp;quot;&lt;p&gt;* the sign &amp;lt; is often used in computer science to mean something else than &amp;quot;lesser than&amp;quot;: in Python and many other languages, &amp;lt;&amp;lt; means left shift; in HTML tags are enclosed with &amp;lt; and &amp;gt;&lt;p&gt;* Python uses the same operator % for very different operations: modulo and string formatting</text></comment>
<story><title>Brython – A Python 3 implementation for client-side web programming</title><url>https://brython.info/</url></story><parent_chain><item><author>linkdd</author><text>What is this monstrosity in the tutorial ?&lt;p&gt;&amp;gt;&amp;gt;&amp;gt; document &amp;lt;= &amp;#x27;Hello!&amp;#x27;  # write in the DOM&lt;p&gt;Since when the __le__ method has any side effects?&lt;p&gt;So to sum it up:&lt;p&gt;- it runs inside the Javascript VM&lt;p&gt;- you change the syntax by breaking the semantics&lt;p&gt;- the import mechanisms is completely different&lt;p&gt;Is it still Python then ?&lt;p&gt;NB: Still, it&amp;#x27;s a fun project and hope you had fun making it.</text></item></parent_chain><comment><author>mjburgess</author><text>It&amp;#x27;s still python; you can overload operators and give them side-effects in any conforming implementation.&lt;p&gt;It may not be &amp;quot;pythonic&amp;quot;, but there&amp;#x27;s an established tradition of operator methods and there&amp;#x27;s no requirement that python code conform to any particular tradition.</text></comment>