setattr question

Gerard Flanagan grflanagan at yahoo.co.uk
Fri Mar 3 05:43:10 EST 2006


bruno at modulix wrote:
[...]
>
> I don't know this HtmlElement class, nor where it comes from.
> 'to_string()' (or is it toString() ?) is javaish. The pythonic idiom for
> this is implementing the __str__() method and calling str(obj) on the
> obj (which will call obj.__str__()). Hence my (bad) guess about you
> being a Javaer.
>

I've made this change, thanks. ( I had a year with C# so maybe that's
why I'm so idiomatically-challenged ! )

> Not the HtmlElement class, but the HtmlBuilder one. Here again, a class
> defining only staticmethods is a pretty javaish idiom - in Python, we
> just use good old functions !-) (in a separate module if you want a
> separate namespace).
>

But it's personal preference, no? The functions were kind of related
and meaningless outside the module they were declared - but I'll take
it on board, anyway.

[...]

>
> My experience is that it's far easier to start simple and add
> flexibility where needed than to simplify useless complexity. KISS,
> yagni and all that kind of things...
>

yagni - I'd never heard that one!

I've ditched the factory class in any case:

    http://gflanagan.net/site/python/htmlbuilder/HtmlBuilder.py
(FWIW)

> >
> > Merci bien pour votre reponse.
> >
> You're welcome.
>
> BTW, there's also a french speaking python newsgroup at fr.comp.lang.py.
>

I wasn't aware of that, I'll have a lurk!

Thanks again.

Gerard

> --
> bruno desthuilliers
> python -c "print '@'.join(['.'.join([w[::-1] for w in p.split('.')]) for
> p in 'onurb at xiludom.gro'.split('@')])"




More information about the Python-list mailing list