Thanks. Why not define the + and += operator for tags? It seems a lot more intuitive to say table+=row
rather than table=TAG[''](table+row) On Jun 28, 2:43 pm, Anthony <[email protected]> wrote: > HTML helper objects do not support the + operator (they don't have an > __add__ method). Your example works because you are concatenating an HTML > helper object with an XML object, and the XML object does support the + > operator -- it does so by calling the __str__ method of both objects and > concatenating the strings (via Python's string formatting syntax). If you > replace var2 with TD("bbbb"), you'll get a syntax error instead of a string > returned. > > If you want to concatenate two (or more) helper objects together without > putting them inside another helper object and without first converting them > to strings, you can put them inside an empty TAG object: > > TAG[''](var1, var2) > > Anthony > > > > > > > > On Tuesday, June 28, 2011 9:17:38 AM UTC-4, apple wrote: > > If I try to concatenate a TD and an XML using += then I end up with a > > string. Why is that? > > > e.g. > > > var1=TD("aaaa") > > var2=XML("bbbb") > > print(type(var1)) > > print(type(var2)) > > var1+=var1 > > print(type(var1)) > > > ===> TD, XML, string > On Tuesday, June 28, 2011 9:17:38 AM UTC-4, apple wrote: > > > If I try to concatenate a TD and an XML using += then I end up with a > > string. Why is that? > > > e.g. > > > var1=TD("aaaa") > > var2=XML("bbbb") > > print(type(var1)) > > print(type(var2)) > > var1+=var1 > > print(type(var1)) > > > ===> TD, XML, string

