what does **kw mean?
Shane Geiger
sgeiger at ncee.net
Fri Jan 11 04:58:52 EST 2008
Does this help?
def foobar(first_name,last_name, *args, **kwargs):
print first_name
print last_name
print "Tuple:",args
print "Dict:",kwargs
x = "has"
y = "demonstrated"
foobar('Shane','Geiger', x, y, adjective='useful', thing='PYTHON trick
known as extended call syntax', adverb='wonderfully')
zslevi at gmail.com wrote:
> I've been reading the following example, and couldn't figure out, what
> **kw mean. (It's an empty dictionary, but what's the semantics):
>
>
> def wrap(method):
> def wrapped(self, *args, **kw):
> print "begin"
> method(self, *args, **kw)
> print "end"
> return wrapped
>
>
> class Test(object):
> def method(self, name):
> print "method(%r)" % name
>
> t = Test()
> t.method("pure")
> Test.method = wrap(Test.method)
> t.method("wrapped")
>
>
--
Shane Geiger
IT Director
National Council on Economic Education
sgeiger at ncee.net | 402-438-8958 | http://www.ncee.net
Leading the Campaign for Economic and Financial Literacy
More information about the Python-list
mailing list