Understanding polymorphism in Python
I'm a bear of very little brain, so I don't really understand what you are trying to achieve, or why you think polymorphism will help you achieve it.

But I did notice some problems with your code:


There's no documentation.
There are no test cases.
Python doesn't need semicolons at the end of lines.
You don't need a \ at the end of a line if the statement cannot end at that point because of an unclosed parenthesis.
There are no checks on the validity of entity and attribute names.
Values aren't escaped.
There's no check to stop the caller adding multiple attributes with the same name.
You shouldn't raise an exception class, you should raise an instance of that class (passing a suitable error message to the constructor).