setattr question
Gerard Flanagan
grflanagan at yahoo.co.uk
Thu Mar 2 17:02:23 EST 2006
Fredrik Lundh wrote:
> Gerard Flanagan wrote:
>
> > I have the following code:
> >
> > #### builder.py #########
> > class HtmlBuilder(object):
> >
> > @staticmethod
> > def page(title=''):
> > return HtmlPage(title)
> >
> > @staticmethod
> > def element(tag, text=None, **attribs):
> > return HtmlElement(tag, text, **attribs)
> >
> > @staticmethod
> > def literal(text):
> > return HtmlLiteral(text)
>
> just curious, but what's the purpose of this class, and what gave
> you the idea to structure your program in this way ?
>
> </F>
In my defense, I can only quote Albert Einstein: "If we knew what it
was we were doing, it would not be called research, would it?" I'm
writing a script to generate a few relatively static webpages and
upload them to a server, but it's as much a learning exercise as
anything else - I have no formal programming education. I thought the
Factory pattern would be appropriate here; the class you quote was a
first attempt and i knew it was undoubtedly the wrong approach, so
that's why i asked the group...
Gerard
More information about the Python-list
mailing list