1 Oct 2009 09:12
Re: Question about lxml.html.builder
Stefan Behnel <stefan_ml <at> behnel.de>
2009-10-01 07:12:39 GMT
2009-10-01 07:12:39 GMT
Joseph Reagle wrote:
> I'm using Python 2.5.2 with lxml 2.1.1-1ubuntu1.
>
> I'm trying to get some version of the lines involving 'wp_ps' to work:
>
> if opts.text:
> wp_ps = [E.P(p) for p in bio.wp_text.split('\n')]
> table.append(
> E.TR(
> E.TD(''),
> E.TD().extend(wp_ps),
> #E.TD(bio.wp_text, colspan='2'),
> E.TD(bio.eb_text, colspan='2'),
> valign="top",
> ),
> )
>
> Simply, I want to take text with LFs and turn them into Ps.
You didn't mention what isn't working here and how it isn't working the way
you expect.
Anyway, without testing, I'd write it this way:
table.append(
E.TR(
E.TD(''),
E.TD(*[E.P(p) for p in bio.wp_text.split('\n')]),
(Continue reading)
RSS Feed