[lxml-dev] Transform parameter variables

Stefan Behnel stefan_ml at behnel.de
Mon Jul 28 13:16:27 CEST 2008


Hi,

it's good practice to

a) reply to the list,
b) avoid top-posting and
c) read what people post.

Niels Bjerre wrote:
> Thank You for your response
>
> But I have problem with the_dict:
> These 2 statements don't give the same result.
>
>    1. newdoc = transform(places.myplaces, area="'3751'")
>    2. newdoc = transform(places.myplaces, {'area':'\"\'3751\'\"'})
>
> 1. is passed to xslt: <xsl:param name="area" select="'ost'"/>
> 2. is ignored
>
> I have tried with
> {'area':'\'3751\''} and others

The last line will work, but as I wrote before:

> 2008/7/28 Stefan Behnel <stefan_ml at behnel.de>
>> You can pass more than one kayword parameter, as everywhere in Python.
>> If you want to pass them from a dictionary, do the usual
>>
>>   result = transform(xml_tree, **the_dict)
>>
>> trick.

Note the two stars before "the_dict". This is standard Python syntax for
expanding a mapping into keyword arguments.

Stefan



More information about the lxml-dev mailing list