[Tutor] Two quick, easy questions ...

Bob Gailer ramrom@earthling.net
Fri Jan 17 21:27:01 2003


--=======20B7174=======
Content-Type: text/plain; x-avg-checked=avg-ok-6DC5BEE; charset=us-ascii; format=flowed
Content-Transfer-Encoding: 8bit

In re *args and **kwargs, also note that one may use these forms when 
passing arguments in a function call:

def a(*b,**c):
   print b, c

t = (1,2,3)
d = {'1':2, '3':4}
a(*t, **d) # results in: (1, 2, 3) {'1': 2, '3': 4}
This can be particularly handy when writing wrapper code around a function 
that expects either form of argument lists.

Also note that

def makedict(**kwargs):return kwargs  # is a great shorthand for creating 
dictionaries
print makedict(a=2,b=4) # results in: {'a': 2, 'b': 4}


Bob Gailer
mailto:ramrom@earthling.net
303 442 2625

--=======20B7174=======
Content-Type: text/plain; charset=us-ascii; x-avg=cert; x-avg-checked=avg-ok-6DC5BEE
Content-Disposition: inline


---
Outgoing mail is certified Virus Free.
Checked by AVG anti-virus system (http://www.grisoft.com).
Version: 6.0.438 / Virus Database: 246 - Release Date: 1/7/2003

--=======20B7174=======--