On Mon, Jun 24, 2013 at 11:34:49AM +1200, Greg Ewing wrote:
Steven D'Aprano wrote:
The special case "parameter name matches exactly argument expression" is far too special, and the benefit far too minor, to deserve special syntax.
It occurs more often than you might think, because taking parameters that you've been passed and passing them on to another function is a common pattern.
Another use case where this would come in handy is with string formatting:
print('{spam} and {eggs}'.format(spam=spam, eggs=eggs))
I've seen people use an awful workaround for this:
print('{spam} and {eggs}'.format(locals()))
While it looks a little magical, the proposed syntax would be an improvement (especially when there are many arguments):
print('{spam} and {eggs}'.format(=spam, =eggs))
I'm not sure if the proposed solution is necessarily the best, but it's not as contrived as some commenters have made it out to be. -- Andrew McNabb http://www.mcnabbs.org/andrew/ PGP Fingerprint: 8A17 B57C 6879 1863 DE55 8012 AB4D 6098 8826 6868