Accessing 'mangled' class attrbutes
Gerard Flanagan
grflanagan at yahoo.co.uk
Wed Mar 1 13:00:27 EST 2006
danmcleran at yahoo.com wrote:
> >>Is there any simple way round this situation in general?
>
> It might be safer to use composition instead of inheritance in this
> case. Assuming that XMLWriter has a write method to write what you
> want, you could hold a reference to an XMLWriter within your class and
> pass along write command like:
>
> writer = XMLWriter()
> writer.write(stuff)
No, XMLWriter doesn't have a 'write' method, if it did I could have
done:
super(HtmlWriter, self).write(stuff)
I think the XMLWriter class has been designed so you can't just write
any old text because this better ensures that tags are properly closed
and so on. There is a public 'data' method:
writer.data( text )
but it escapes angle brackets, and what i wanted was to write
'<!DOCTYPE.....'.
Thanks
Gerard
More information about the Python-list
mailing list