DTD Parsing

Felipe Bastos Nunes felipe.bastosn at gmail.com
Wed Nov 10 07:34:06 EST 2010


I'll look at the options. But anyway, only to give an example of the
configs I told, the ShoX project (at sourceforge.net) has xml as
config files. I'm not talking about common users to edit the xmls,
it's about the developer edit them :-) I'm working in a python
wireless sensor network simulator, some builtin functions at python
will greatly increase the ease in doing this.

Does any, libxml2 or lxml, collect children like jdom does in java?
    List<Element> children = myRoot.getChildren();

Or just doing a Handler to find the children?

2010/11/10, Ian Kelly <ian.g.kelly at gmail.com>:
> On 11/9/2010 11:14 PM, r0g wrote:
>> Me too when possible, TBH if I only needed strings and there was no
>> pressing security issue I'd just do this...
>>
>> config = {}
>> for line in (open("config.txt", 'r')):
>> if len(line) > 0 and line[0] <> "#":
>> param, value = line.rstrip().split("=",1)
>> config[param] = value
>
> That's five whole lines of code.  Why go to all that trouble when you
> can just do this:
>
> import config
>
> I kid, but only partially.  Where this really shines is when you're
> prototyping something and you need to configure complex object
> hierarchies.  No need to spend time writing parsers to generate the
> hierarchies; you just construct the objects directly in the config.
> When the project becomes mature enough that configuration security is a
> concern, then you can replace the config with XML or whatever, and in
> the meantime you can focus on more important things, like the actual
> project.
>
> Cheers,
> Ian
>
> --
> http://mail.python.org/mailman/listinfo/python-list
>


-- 
Felipe Bastos Nunes



More information about the Python-list mailing list