Message82862
The normal use of a keyword argument is to refer to a formal argument,
which is an identifier. Being able to wrap it up into a dict is a later
addition, and it's necessary to turn the identifier into a string
because it's not possible to use a bare word (as Perl would call it) as
a key (I can't think of any other place where something is automatically
turned into a string). Of course, another approach would've been to make
them attributes of the formal argument:
def foo(**args):
print "a is %s" % args.a
foo(a=1)
As for it being an exception to the rule, well, many things can be a
key: an integer could be a key. Would foo(0="zero") be OK? There's no
syntactic reason why it couldn't be allowed.
-1 from me. |
|
Date |
User |
Action |
Args |
2009-02-27 19:30:07 | mrabarnett | set | recipients:
+ mrabarnett, georg.brandl, LambertDW, Imagist |
2009-02-27 19:30:07 | mrabarnett | set | messageid: <1235763007.0.0.613762324529.issue5382@psf.upfronthosting.co.za> |
2009-02-27 19:30:05 | mrabarnett | link | issue5382 messages |
2009-02-27 19:30:04 | mrabarnett | create | |
|