Order of keyword arguments
Jeff
jam at quark.emich.edu
Sun Nov 21 11:48:27 EST 1999
On Sun, Nov 21, 1999 at 10:28:18AM -0500, Andres Corrada wrote:
>
> I want to have my cake and eat it too! I thought this would be a way of
> keeping the flexibity of keyword arguments but also pass information
> along on how the calling function wants the items returned. For example,
> an HTML form could be called with a variable number of input tags and
> you want to render the HTML in the same order that they were used to
> call the function.
>
hmmm.. well, you can't do it that way ;)
you can write your function such that the order in which the arguments are
processed is static (using kw.items() and a series of if..then statements in
some specific order) in order to get this done, but I don't see the
advantage to 'knowing' the order that the keywords were used by the calling
function.
I have used something like this:
def foo(**kw):
for k,v in kw.items():
if k == "bar":
print "bar keyword value:",v
elif k == "baz":
print "baz keyword value:", v
.
.
.
in code that was building arguments to pass to ipchains, and it seems to
work OK. does that help?
regards,
J
--
|| visit gfd <http://quark.emich.edu/>
|| psa member #293 <http://www.python.org/>
|| New Image Systems & Services, Inc. <http://www.newimage.com/>
More information about the Python-list
mailing list