Having problems accepting parameters to a function
rh0dium
steven.klass at gmail.com
Tue May 1 12:38:08 EDT 2007
Hi Experts!!
I am trying to get the following little snippet to push my data to the
function func(). What I would expect to happen is it to print out the
contents of a and loglevel. But it's not working. Can someone please
help me out.
---------<snip>--------------
#!/usr/bin/env python
import random
def func(*args, **kwargs):
print kwargs.get('a', "NOPE")
print kwargs.get('loglevel', "NO WAY")
def main():
b = []
for x in range(5):
b.append({'a':random.random(), "loglevel":10})
for y in b:
apply(func,y)
# First attempt - didn't work
# for y in b:
# func(y)
if __name__ == '__main__':
main()
More information about the Python-list
mailing list