On Fri, 2010-08-20 at 14:32 +0200, Hans Meine wrote: > That does not sound like zen-compatible python to me. :-) > ("Explicit is better than implicit") > > FWIW, the __setitem__ looks very good to me.
I agree. Having implicit conversion between dashes and underscores makes the API cleaner, since you can reference XML attributes the same way you reference python attributes and you can pass attributes as kwargs. That is: >>> node.add_child('url', 'http://foo', mplayer_options='-demuxer lavf') >>> print node.mplayer_options Versus: >>> node.add_child('url', 'http://foo') >>> node['mplayer-options'] = '-demuxer lavf' >>> print node['mplayer-options'] The former is more magical, but perhaps more intuitive. But it has the (I think fatal) flaw of conflicting with the Node class namespace, so you could never have an attribute called, for example, 'save'. And it is, as you say, not zen-compatible. Instead of accepting kwargs for add_child, I'd prefer explicitly accepting a dict, and always using __getitem__/__setitem__ to avoid the collision problem with python attributes. >>> node.add_child('url', 'http://foo', {'mplayer-options': '-demuxer lavf'}) >>> print node['mplayer-options'] dischi, can we deprecate __getattr__ and the kwarg support in add_child? (I'll implement it.) ------------------------------------------------------------------------------ This SF.net email is sponsored by Make an app they can't live without Enter the BlackBerry Developer Challenge http://p.sf.net/sfu/RIM-dev2dev _______________________________________________ Freevo-devel mailing list Freevo-devel@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/freevo-devel