[issue5383] Allow intermixing of keyword arguments and vargarg arguments

Ezio Melotti report at bugs.python.org
Fri Feb 27 19:25:09 CET 2009


Ezio Melotti <ezio.melotti at gmail.com> added the comment:

> xhtmlNode('div','Hello, world',id='sidebar')

> ... but this would not have symmetry with the generated xhtml and 
> therefore complicates the code.  The solution, in my opinion, is to 
> allow varargs to be intermixed with keyword args.  The above real-world 
> example shows a use-case for this more flexible functionality.

IMHO your API is confusing in the first place, if xhtmlNode is supposed
to create an XHTML element (possibly with attributes), why would you
want to pass also the content as a positional argument?

I would probably keep the element and its content separate and do
something like:
div = xhtmlNode('div', **attributes)
div.add(TextNode('Hello World'))

or, if you want a shortcut:
xhtmlNode('div', id='sidebar', content='Hello world') or
xhtmlNode('div', id='sidebar', text='Hello world')

----------
nosy: +ezio.melotti

_______________________________________
Python tracker <report at bugs.python.org>
<http://bugs.python.org/issue5383>
_______________________________________


More information about the Python-bugs-list mailing list